Skip to content

Commit f6829da

Browse files
chore: address commit comments
PR-URL: #5320 Closes: #5304 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 41fd19a commit f6829da

File tree

4 files changed

+11
-22
lines changed

4 files changed

+11
-22
lines changed

lib/node_modules/@stdlib/stats/base/dists/uniform/stdev/lib/main.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@
1818

1919
'use strict';
2020

21-
// MODULES //
22-
23-
var sqrt = require( '@stdlib/math/base/special/sqrt' );
24-
25-
2621
// VARIABLES //
2722

28-
var SQRT1O12 = sqrt( 1.0/12.0 );
23+
var SQRT1O12 = 0.28867513459481287; // sqrt( 1.0/12.0 );
2924

3025

3126
// MAIN //

lib/node_modules/@stdlib/stats/base/dists/uniform/stdev/src/main.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "stdlib/stats/base/dists/uniform/stdev.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21-
#include "stdlib/math/base/special/sqrt.h"
2221

2322
/**
2423
* Returns the standard deviation of a uniform distribution.
@@ -31,6 +30,9 @@
3130
* double v = stdev( 4.0, 12.0 );
3231
* // returns ~2.309
3332
*/
33+
34+
static const double SQRT_ONE_TWELFTH = 0.28867513459481287; // stdlib_base_sqrt( 1.0/12.0 )
35+
3436
double stdlib_base_dists_uniform_stdev( const double a, const double b ) {
3537
if (
3638
stdlib_base_is_nan( a ) ||
@@ -39,5 +41,5 @@ double stdlib_base_dists_uniform_stdev( const double a, const double b ) {
3941
) {
4042
return 0.0 / 0.0; // NaN
4143
}
42-
return stdlib_base_sqrt( 1.0/12.0 ) * ( b-a );
44+
return SQRT_ONE_TWELFTH * ( b-a );
4345
}

lib/node_modules/@stdlib/stats/base/dists/uniform/stdev/test/test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,9 @@ tape( 'the function returns the standard deviation of a uniform distribution', f
8484
b = data.b;
8585
for ( i = 0; i < expected.length; i++ ) {
8686
y = stdev( a[i], b[i] );
87-
if ( y === expected[i] ) {
88-
t.equal( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
89-
} else {
90-
delta = abs( y - expected[ i ] );
91-
tol = 1.0 * EPS * abs( expected[ i ] );
92-
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
93-
}
87+
delta = abs( y - expected[ i ] );
88+
tol = 1.0 * EPS * abs( expected[ i ] );
89+
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
9490
}
9591
t.end();
9692
});

lib/node_modules/@stdlib/stats/base/dists/uniform/stdev/test/test.native.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,9 @@ tape( 'the function returns the standard deviation of a uniform distribution', o
9393
b = data.b;
9494
for ( i = 0; i < expected.length; i++ ) {
9595
y = stdev( a[i], b[i] );
96-
if ( y === expected[i] ) {
97-
t.equal( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
98-
} else {
99-
delta = abs( y - expected[ i ] );
100-
tol = 1.0 * EPS * abs( expected[ i ] );
101-
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
102-
}
96+
delta = abs( y - expected[ i ] );
97+
tol = 1.0 * EPS * abs( expected[ i ] );
98+
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
10399
}
104100
t.end();
105101
});

0 commit comments

Comments
 (0)