Skip to content

Commit 2aeee4c

Browse files
committed
feat: add stats/strided/dnanvarianceyc
Ref: #4797 --- 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 2b2ef00 commit 2aeee4c

37 files changed

+4457
-0
lines changed

lib/node_modules/@stdlib/stats/strided/dnanvarianceyc/README.md

Lines changed: 397 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
27+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var pow = require( '@stdlib/math/base/special/pow' );
29+
var pkg = require( './../package.json' ).name;
30+
var dnanvarianceyc = require( './../lib/dnanvarianceyc.js' );
31+
32+
33+
// FUNCTIONS //
34+
35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.8 ) < 1 ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
48+
/**
49+
* Creates a benchmark function.
50+
*
51+
* @private
52+
* @param {PositiveInteger} len - array length
53+
* @returns {Function} benchmark function
54+
*/
55+
function createBenchmark( len ) {
56+
var x = filledarrayBy( len, 'float64', rand );
57+
return benchmark;
58+
59+
function benchmark( b ) {
60+
var v;
61+
var i;
62+
63+
b.tic();
64+
for ( i = 0; i < b.iterations; i++ ) {
65+
v = dnanvarianceyc( x.length, 1, x, 1 );
66+
if ( isnan( v ) ) {
67+
b.fail( 'should not return NaN' );
68+
}
69+
}
70+
b.toc();
71+
if ( isnan( v ) ) {
72+
b.fail( 'should not return NaN' );
73+
}
74+
b.pass( 'benchmark finished' );
75+
b.end();
76+
}
77+
}
78+
79+
80+
// MAIN //
81+
82+
/**
83+
* Main execution sequence.
84+
*
85+
* @private
86+
*/
87+
function main() {
88+
var len;
89+
var min;
90+
var max;
91+
var f;
92+
var i;
93+
94+
min = 1; // 10^min
95+
max = 6; // 10^max
96+
97+
for ( i = min; i <= max; i++ ) {
98+
len = pow( 10, i );
99+
f = createBenchmark( len );
100+
bench( pkg+':len='+len, f );
101+
}
102+
}
103+
104+
main();
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
27+
var filledarrayBy = require( '@stdlib/array/filled-by' );
28+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var pow = require( '@stdlib/math/base/special/pow' );
30+
var tryRequire = require( '@stdlib/utils/try-require' );
31+
var pkg = require( './../package.json' ).name;
32+
33+
34+
// VARIABLES //
35+
36+
var dnanvarianceyc = tryRequire( resolve( __dirname, './../lib/dnanvarianceyc.native.js' ) );
37+
var opts = {
38+
'skip': ( dnanvarianceyc instanceof Error )
39+
};
40+
41+
42+
// FUNCTIONS //
43+
44+
/**
45+
* Returns a random value or `NaN`.
46+
*
47+
* @private
48+
* @returns {number} random number or `NaN`
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.8 ) < 1 ) {
52+
return NaN;
53+
}
54+
return uniform( -10.0, 10.0 );
55+
}
56+
57+
/**
58+
* Creates a benchmark function.
59+
*
60+
* @private
61+
* @param {PositiveInteger} len - array length
62+
* @returns {Function} benchmark function
63+
*/
64+
function createBenchmark( len ) {
65+
var x = filledarrayBy( len, 'float64', rand );
66+
return benchmark;
67+
68+
function benchmark( b ) {
69+
var v;
70+
var i;
71+
72+
b.tic();
73+
for ( i = 0; i < b.iterations; i++ ) {
74+
v = dnanvarianceyc( x.length, 1, x, 1 );
75+
if ( isnan( v ) ) {
76+
b.fail( 'should not return NaN' );
77+
}
78+
}
79+
b.toc();
80+
if ( isnan( v ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
}
86+
}
87+
88+
89+
// MAIN //
90+
91+
/**
92+
* Main execution sequence.
93+
*
94+
* @private
95+
*/
96+
function main() {
97+
var len;
98+
var min;
99+
var max;
100+
var f;
101+
var i;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( i = min; i <= max; i++ ) {
107+
len = pow( 10, i );
108+
f = createBenchmark( len );
109+
bench( pkg+'::native:len='+len, opts, f );
110+
}
111+
}
112+
113+
main();
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
27+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var pow = require( '@stdlib/math/base/special/pow' );
29+
var pkg = require( './../package.json' ).name;
30+
var dnanvarianceyc = require( './../lib/ndarray.js' );
31+
32+
33+
// FUNCTIONS //
34+
35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.8 ) < 1 ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
48+
/**
49+
* Creates a benchmark function.
50+
*
51+
* @private
52+
* @param {PositiveInteger} len - array length
53+
* @returns {Function} benchmark function
54+
*/
55+
function createBenchmark( len ) {
56+
var x = filledarrayBy( len, 'float64', rand );
57+
return benchmark;
58+
59+
function benchmark( b ) {
60+
var v;
61+
var i;
62+
63+
b.tic();
64+
for ( i = 0; i < b.iterations; i++ ) {
65+
v = dnanvarianceyc( x.length, 1, x, 1, 0 );
66+
if ( isnan( v ) ) {
67+
b.fail( 'should not return NaN' );
68+
}
69+
}
70+
b.toc();
71+
if ( isnan( v ) ) {
72+
b.fail( 'should not return NaN' );
73+
}
74+
b.pass( 'benchmark finished' );
75+
b.end();
76+
}
77+
}
78+
79+
80+
// MAIN //
81+
82+
/**
83+
* Main execution sequence.
84+
*
85+
* @private
86+
*/
87+
function main() {
88+
var len;
89+
var min;
90+
var max;
91+
var f;
92+
var i;
93+
94+
min = 1; // 10^min
95+
max = 6; // 10^max
96+
97+
for ( i = min; i <= max; i++ ) {
98+
len = pow( 10, i );
99+
f = createBenchmark( len );
100+
bench( pkg+':ndarray:len='+len, f );
101+
}
102+
}
103+
104+
main();

0 commit comments

Comments
 (0)