Skip to content

Commit b6ad3e2

Browse files
committed
chore: clean-up
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 367e8f9 commit b6ad3e2

File tree

5 files changed

+36
-34
lines changed

5 files changed

+36
-34
lines changed

lib/node_modules/@stdlib/stats/base/dists/cosine/mean/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ for ( i = 0; i < 10; i++ ) {
157157
#include "stdlib/stats/base/dists/cosine/mean.h"
158158
```
159159

160-
#### stdlib_base_dists_cosine_mean( a, b )
160+
#### stdlib_base_dists_cosine_mean( mu, s )
161161

162162
Returns the [expected value][mean] for a [raised cosine][cosine-distribution] distribution with location parameter `mu` and scale parameter `s`.
163163

lib/node_modules/@stdlib/stats/base/dists/cosine/mean/benchmark/benchmark.native.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,27 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( 'path' ).resolve;
2324
var bench = require( '@stdlib/bench' );
2425
var Float64Array = require( '@stdlib/array/float64' );
2526
var uniform = require( '@stdlib/random/base/uniform' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var EPS = require( '@stdlib/constants/float64/eps' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
2830
var pkg = require( './../package.json' ).name;
29-
var mean = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var mean = tryRequire( resolve( __dirname, './../lib/native.js' ) );
36+
var opts = {
37+
'skip': ( mean instanceof Error )
38+
};
3039

3140

3241
// MAIN //
3342

34-
bench( pkg, function benchmark( b ) {
43+
bench( pkg+'::native', opts, function benchmark( b ) {
3544
var len;
3645
var mu;
3746
var s;

lib/node_modules/@stdlib/stats/base/dists/cosine/mean/benchmark/c/benchmark.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,39 @@ static double tic( void ) {
7474
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
7575
}
7676

77+
/**
78+
* Generates a random number on the interval [min,max).
79+
*
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
83+
*/
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) );
87+
}
88+
7789
/**
7890
* Runs a benchmark.
7991
*
8092
* @return elapsed time in seconds
8193
*/
8294
static double benchmark( void ) {
8395
double elapsed;
84-
double mu;
85-
double s;
96+
double mu[ 100 ];
97+
double s[ 100 ];
8698
double y;
8799
double t;
88100
int i;
89101

102+
for ( i = 0; i < 100; i++ ) {
103+
mu[ i ] = random_uniform( -50.0, 50.0 );
104+
s[ i ] = random_uniform( 1.0, 20.0 );
105+
}
106+
90107
t = tic();
91108
for ( i = 0; i < ITERATIONS; i++ ) {
92-
mu = 100.0*( (double)rand() / (double)RAND_MAX ) - 50.0;
93-
s = 20.0*( (double)rand() / (double)RAND_MAX );
94-
y = stdlib_base_dists_cosine_mean( mu, s );
109+
y = stdlib_base_dists_cosine_mean( mu[ i%100 ], s[ i%100 ] );
95110
if ( y != y ) {
96111
printf( "should not return NaN\n" );
97112
break;

lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222

2323
var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25-
var abs = require( '@stdlib/math/base/special/abs' );
2625
var PINF = require( '@stdlib/constants/float64/pinf' );
2726
var NINF = require( '@stdlib/constants/float64/ninf' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var mean = require( './../lib' );
3028

3129

@@ -79,8 +77,6 @@ tape( 'if provided a nonpositive `s`, the function returns `NaN`', function test
7977

8078
tape( 'the function returns the expected value of a raised cosine distribution', function test( t ) {
8179
var expected;
82-
var delta;
83-
var tol;
8480
var mu;
8581
var s;
8682
var y;
@@ -91,15 +87,7 @@ tape( 'the function returns the expected value of a raised cosine distribution',
9187
s = data.s;
9288
for ( i = 0; i < mu.length; i++ ) {
9389
y = mean( mu[i], s[i] );
94-
if ( expected[i] !== null ) {
95-
if ( y === expected[i] ) {
96-
t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
97-
} else {
98-
delta = abs( y - expected[ i ] );
99-
tol = 1.0 * EPS * abs( expected[ i ] );
100-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
101-
}
102-
}
90+
t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
10391
}
10492
t.end();
10593
});

lib/node_modules/@stdlib/stats/base/dists/cosine/mean/test/test.native.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
26-
var abs = require( '@stdlib/math/base/special/abs' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var PINF = require( '@stdlib/constants/float64/pinf' );
2928
var NINF = require( '@stdlib/constants/float64/ninf' );
30-
var EPS = require( '@stdlib/constants/float64/eps' );
3129

3230

3331
// VARIABLES //
@@ -84,25 +82,17 @@ tape( 'if provided `s <= 0.0`, the function returns `NaN`', opts, function test(
8482

8583
tape( 'the function returns the mean of a cosine distribution', opts, function test( t ) {
8684
var expected;
87-
var delta;
88-
var tol;
8985
var mu;
9086
var s;
91-
var i;
9287
var y;
88+
var i;
9389

9490
expected = data.expected;
9591
mu = data.mu;
9692
s = data.s;
97-
for ( i = 0; i < expected.length; i++ ) {
93+
for ( i = 0; i < mu.length; i++ ) {
9894
y = mean( mu[i], s[i] );
99-
if ( y === expected[i] ) {
100-
t.equal( y, expected[i], 'mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
101-
} else {
102-
delta = abs( y - expected[ i ] );
103-
tol = 1.0 * EPS * abs( expected[ i ] );
104-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
105-
}
95+
t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
10696
}
10797
t.end();
10898
});

0 commit comments

Comments
 (0)