Skip to content

Commit 3dd231f

Browse files
committed
chore: stuff from code review
1 parent 68432ed commit 3dd231f

File tree

6 files changed

+54
-22
lines changed

6 files changed

+54
-22
lines changed

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ double out = stdlib_base_dists_arcsine_kurtosis( 0.0, 2.0 );
168168

169169
The function accepts the following arguments:
170170

171-
- **a**: `[in] double` minimum support
172-
- **b**: `[in] double` maximum support
171+
- **a**: `[in] double` minimum support.
172+
- **b**: `[in] double` maximum support.
173173

174174
```c
175175
double stdlib_base_dists_arcsine_kurtosis( const double a, const double b );
@@ -203,10 +203,15 @@ int main( void ) {
203203
double b;
204204
double y;
205205
int i;
206+
207+
static double random_uniform( const double min, const double max ) {
208+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
209+
return min + ( v * ( max - min ) );
210+
}
206211
207212
for ( i = 0; i < 25; i++ ) {
208-
a = ( (double)rand() / (double)RAND_MAX ) * 20.0 - 20.0;
209-
b = a + ( (double)rand() / (double)RAND_MAX ) * 40.0;
213+
a = random_uniform( 0, 20 );
214+
b = random_uniform( 0, 20 ) + a;
210215
y = stdlib_base_dists_arcsine_kurtosis( a, b );
211216
printf( "a: %lf, b: %lf, Kurt(X;a,b): %lf\n", a, b, y );
212217
}

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/benchmark/benchmark.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
2425
var randu = require( '@stdlib/random/base/randu' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var pkg = require( './../package.json' ).name;
@@ -32,14 +33,21 @@ var kurtosis = require( './../lib' );
3233
bench( pkg, function benchmark( b ) {
3334
var min;
3435
var max;
36+
var len;
3537
var y;
3638
var i;
3739

40+
len = 100;
41+
min = new Float64Array( len );
42+
max = new Float64Array( len );
43+
for ( i = 0; i < len; i++ ) {
44+
min[ i ] = randu() * 20.0;
45+
max[ i ] = ( randu() * 20.0 ) + min;
46+
}
47+
3848
b.tic();
3949
for ( i = 0; i < b.iterations; i++ ) {
40-
min = ( randu()*10.0 );
41-
max = ( randu()*10.0 ) + min;
42-
y = kurtosis( min, max );
50+
y = kurtosis( min[ i % len ], max[ i % len ] );
4351
if ( isnan( y ) ) {
4452
b.fail( 'should not return NaN' );
4553
}

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/benchmark/benchmark.native.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25+
var Float64Array = require( '@stdlib/array/float64' );
2526
var tryRequire = require( '@stdlib/utils/try-require' );
2627
var randu = require( '@stdlib/random/base/randu' );
2728
var isnan = require( '@stdlib/math/base/assert/is-nan' );
@@ -41,14 +42,21 @@ var opts = {
4142
bench( pkg, opts, function benchmark( b ) {
4243
var min;
4344
var max;
45+
var len;
4446
var y;
4547
var i;
4648

49+
len = 100;
50+
min = new Float64Array( len );
51+
max = new Float64Array( len );
52+
for ( i = 0; i < len; i++ ) {
53+
min[ i ] = randu() * 20.0;
54+
max[ i ] = ( randu() * 20.0 ) + min;
55+
}
56+
4757
b.tic();
4858
for ( i = 0; i < b.iterations; i++ ) {
49-
min = ( randu()*10.0 );
50-
max = ( randu()*10.0 ) + min;
51-
y = kurtosis( min, max );
59+
y = kurtosis( min[ i % len ], max[ i % len ] );
5260
if ( isnan( y ) ) {
5361
b.fail( 'should not return NaN' );
5462
}

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/benchmark/c/benchmark.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -91,17 +93,20 @@ static double rand_double( void ) {
9193
*/
9294
static double benchmark( void ) {
9395
double elapsed;
94-
double min;
95-
double max;
96+
double min[ 100 ];
97+
double max[ 100 ];
9698
double y;
9799
double t;
98100
int i;
99101

102+
for ( i = 0; i < 100; i++ ) {
103+
min[ i ] = random_uniform( 0, 20 );
104+
max[ i ] = random_uniform( 0, 20 ) + min;
105+
}
106+
100107
t = tic();
101108
for ( i = 0; i < ITERATIONS; i++ ) {
102-
min = ( 20.0*rand_double() ) - 20.0;
103-
max = min + ( 40.0*rand_double() );
104-
y = stdlib_base_dists_arcsine_kurtosis( min, max );
109+
y = stdlib_base_dists_arcsine_kurtosis( min[ i % 100 ], max[ i % 100 ] );
105110
if ( y != y ) {
106111
printf( "should not return NaN\n" );
107112
break;

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/examples/c/example.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@
2020
#include <stdlib.h>
2121
#include <stdio.h>
2222

23+
static double random_uniform( const double min, const double max ) {
24+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
25+
return min + ( v*(max-min) );
26+
}
27+
2328
int main( void ) {
2429
double a;
2530
double b;
2631
double y;
2732
int i;
2833

2934
for ( i = 0; i < 25; i++ ) {
30-
a = ( (double)rand() / (double)RAND_MAX ) * 20.0 - 20.0;
31-
b = a + ( (double)rand() / (double)RAND_MAX ) * 40.0;
35+
a = random_uniform( 0, 20 );
36+
b = random_uniform( 0, 20 ) + a;
3237
y = stdlib_base_dists_arcsine_kurtosis( a, b );
3338
printf( "a: %lf, b: %lf, Kurt(X;a,b): %lf\n", a, b, y );
3439
}

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/lib/native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' );
2828
/**
2929
* Returns the excess kurtosis of an arcsine distribution.
3030
*
31+
* @private
3132
* @param {number} a - minimum support
3233
* @param {number} b - maximum support
3334
* @returns {number} excess kurtosis

0 commit comments

Comments
 (0)