Skip to content

Commit ae9a8a7

Browse files
committed
chore: minor 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: passed - task: lint_repl_help status: na - 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: na - 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: na - 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 0c1b1ea commit ae9a8a7

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

lib/node_modules/@stdlib/stats/incr/nanhmean/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ v = accumulator();
103103
<!-- eslint no-undef: "error" -->
104104

105105
```javascript
106-
var randu = require( '@stdlib/random/base/randu' );
106+
var uniform = require( '@stdlib/random/base/uniform' );
107+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
107108
var incrnanhmean = require( '@stdlib/stats/incr/nanhmean' );
108109

109110
var accumulator;
@@ -115,10 +116,10 @@ accumulator = incrnanhmean();
115116

116117
// For each simulated datum, update the harmonic mean...
117118
for ( i = 0; i < 100; i++ ) {
118-
if ( randu() < 0.2 ) {
119+
if ( bernoulli( 0.2 ) ) {
119120
v = NaN;
120121
} else {
121-
v = ( randu()*100.0 );
122+
v = uniform( 1.0, 100.0 );
122123
}
123124
accumulator( v );
124125
}

lib/node_modules/@stdlib/stats/incr/nanhmean/examples/index.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,21 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/base/uniform' );
22+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
2223
var incrnanhmean = require( './../lib' );
2324

24-
var accumulator;
25-
var mu;
26-
var v;
27-
var i;
28-
2925
// Initialize an accumulator:
30-
accumulator = incrnanhmean();
26+
var accumulator = incrnanhmean();
3127

3228
// For each simulated datum, update the harmonic mean...
3329
console.log( '\nValue\tHarmonic Mean\n' );
30+
var mu;
31+
var v;
32+
var i;
3433
for ( i = 0; i < 100; i++ ) {
35-
if ( randu() < 0.2 ) {
36-
v = NaN;
37-
} else {
38-
v = ( randu()*100.0 );
39-
}
34+
v = ( bernoulli( 0.2 ) ) ? NaN : uniform( 1.0, 100.0 );
4035
mu = accumulator( v );
41-
console.log( '%d\t%d', ( v === null) ? NaN : v.toFixed( 4 ), ( mu === null) ? NaN : mu.toFixed( 4 ) );
36+
console.log( '%d\t%d', v.toFixed( 4 ), ( mu === null ) ? NaN : mu.toFixed( 4 ) );
4237
}
4338
console.log( '\nFinal harmonic mean: %d\n', accumulator() );

lib/node_modules/@stdlib/stats/incr/nanhmean/lib/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ function incrnanhmean() {
8080
* @returns {(number|null)} harmonic mean or null
8181
*/
8282
function accumulator( x ) {
83-
if ( arguments.length === 0 || isnan( x )) {
83+
if ( arguments.length === 0 || isnan( x ) ) {
8484
return hmean();
8585
}
86-
return hmean(x);
86+
return hmean( x );
8787
}
8888
}
8989

lib/node_modules/@stdlib/stats/incr/nanhmean/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/stats/incr/nanhmean",
33
"version": "0.0.0",
4-
"description": "Compute a harmonic mean incrementally.",
4+
"description": "Compute a harmonic mean incrementally, ignoring NaN values.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",
@@ -62,6 +62,8 @@
6262
"harmonic mean",
6363
"central tendency",
6464
"incremental",
65-
"accumulator"
65+
"accumulator",
66+
"nan",
67+
"ignore"
6668
]
6769
}

lib/node_modules/@stdlib/stats/incr/nanhmean/test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var abs = require( '@stdlib/math/base/special/abs' );
2626
var EPSILON = require( '@stdlib/constants/float64/eps' );
27-
var incrnanhmean = require( '@stdlib/stats/incr/nanhmean/lib' );
27+
var incrnanhmean = require( './../lib' );
2828

2929

3030
// TESTS //
@@ -68,10 +68,10 @@ tape( 'the accumulator function incrementally computes a harmonic mean', functio
6868
j = 0;
6969
for ( i = 0; i < N; i++ ) {
7070
d = data[ i ];
71-
if ( !isnan(d) ) {
71+
if ( !isnan( d ) ) {
7272
sum += 1.0 / d;
7373
expected = (j+1) / sum;
74-
j+=1;
74+
j += 1;
7575
}
7676
actual = acc( d );
7777
if ( actual === expected ) {

0 commit comments

Comments
 (0)