File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed
lib/node_modules/@stdlib/stats/base/nanmaxabs/examples Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change 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.
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 ' ) ;
2424var 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 ) ;
3734console . log ( x ) ;
3835
3936var v = nanmaxabs ( x . length , x , 1 ) ;
You can’t perform that action at this time.
0 commit comments