Skip to content

Commit

Permalink
docs: refactor examples of stats/base/dnanmax
Browse files Browse the repository at this point in the history
PR-URL: #4781
Co-authored-by: Athan Reines <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
  • Loading branch information
aayush0325 and kgryte authored Jan 16, 2025
1 parent 4d14525 commit ad4a4ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
21 changes: 9 additions & 12 deletions lib/node_modules/@stdlib/stats/base/dnanmax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,19 @@ var v = dnanmax.ndarray( 4, x, 2, 1 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanmax = require( '@stdlib/stats/base/dnanmax' );

var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
if ( randu() < 0.2 ) {
x[ i ] = NaN;
} else {
x[ i ] = round( (randu()*100.0) - 50.0 );
function rand() {
if ( bernoulli( 0.2 ) < 1 ) {
return NaN;
}
return uniform( -50.0, 50.0 );
}

var x = filledarrayBy( 10, 'float64', rand );
console.log( x );

var v = dnanmax( x.length, x, 1 );
Expand Down
21 changes: 9 additions & 12 deletions lib/node_modules/@stdlib/stats/base/dnanmax/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanmax = require( './../lib' );

var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
if ( randu() < 0.2 ) {
x[ i ] = NaN;
} else {
x[ i ] = round( (randu()*100.0) - 50.0 );
function rand() {
if ( bernoulli( 0.2 ) < 1 ) {
return NaN;
}
return uniform( -50.0, 50.0 );
}

var x = filledarrayBy( 10, 'float64', rand );
console.log( x );

var v = dnanmax( x.length, x, 1 );
Expand Down

1 comment on commit ad4a4ce

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
stats/base/dnanmax $\color{green}380/380$
$\color{green}+100.00\%$
$\color{green}31/31$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}380/380$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.