Skip to content

Commit 6b5d0e9

Browse files
authored
Update index.js
Signed-off-by: Kaushikgtm <[email protected]>
1 parent 7195c03 commit 6b5d0e9

File tree

1 file changed

+10
-13
lines changed
  • lib/node_modules/@stdlib/stats/base/nanmaxabs/examples

1 file changed

+10
-13
lines changed

lib/node_modules/@stdlib/stats/base/nanmaxabs/examples/index.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,22 +18,19 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
23-
var Float64Array = require( '@stdlib/array/float64' );
21+
var uniform = require( '@stdlib/random/base/uniform' );
22+
var filledarrayBy = require( '@stdlib/array/filled-by' );
23+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
2424
var nanmaxabs = require( './../lib' );
2525

26-
var x;
27-
var i;
28-
29-
x = new Float64Array( 10 );
30-
for ( i = 0; i < x.length; i++ ) {
31-
if ( randu() < 0.2 ) {
32-
x[ i ] = NaN;
33-
} else {
34-
x[ i ] = round( (randu()*100.0) - 50.0 );
26+
function rand() {
27+
if ( bernoulli( 0.8 ) < 1 ) {
28+
return NaN;
3529
}
30+
return uniform( -50.0, 50.0 );
3631
}
32+
33+
var x = filledarrayBy( 10, 'float64', rand );
3734
console.log( x );
3835

3936
var v = nanmaxabs( x.length, x, 1 );

0 commit comments

Comments
 (0)