Skip to content

docs: replace manual for loop in examples #6793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions lib/node_modules/@stdlib/stats/base/dists/beta/mgf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,19 @@ y = mymgf( 0.3 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var mgf = require( '@stdlib/stats/base/dists/beta/mgf' );

var alpha;
var beta;
var t;
var v;
var i;

for ( i = 0; i < 10; i++ ) {
t = randu() * 20.0;
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
v = mgf( t, alpha, beta );
console.log( 't: %d, α: %d, β: %d, M_X(t;α,β): %d', t.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var t = uniform( 10, 0.0, 20.0, opts );

logEachMap( 't: %0.4f, α: %0.4f, β: %0.4f, M_X(t;α,β): %0.4f', t, alpha, beta, mgf );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var mgf = require( './../lib' );

var alpha;
var beta;
var t;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var t = uniform( 10, 0.0, 20.0, opts );

for ( i = 0; i < 10; i++ ) {
t = randu() * 20.0;
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
v = mgf( t, alpha, beta );
console.log( 't: %d, α: %d, β: %d, M_X(t;α,β): %d', t.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 't: %0.4f, α: %0.4f, β: %0.4f, M_X(t;α,β): %0.4f', t, alpha, beta, mgf );
19 changes: 8 additions & 11 deletions lib/node_modules/@stdlib/stats/base/dists/beta/mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,17 @@ v = mode( 1.0, -1.0 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var mode = require( '@stdlib/stats/base/dists/beta/mode' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, 1.0, 10.0, opts );
var beta = uniform( 10, 1.0, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + 1.0;
beta = ( randu()*10.0 ) + 1.0;
v = mode( alpha, beta );
console.log( 'α: %d, β: %d, mode(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, mode(X;α,β): %0.4f', alpha, beta, mode );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var mode = require( './../lib' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, 1.0, 10.0, opts );
var beta = uniform( 10, 1.0, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + 1.0;
beta = ( randu()*10.0 ) + 1.0;
v = mode( alpha, beta );
console.log( 'α: %d, β: %d, mode(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, mode(X;α,β): %0.4f', alpha, beta, mode );
24 changes: 10 additions & 14 deletions lib/node_modules/@stdlib/stats/base/dists/beta/pdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,19 @@ y = mypdf( 0.3 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pdf = require( '@stdlib/stats/base/dists/beta/pdf' );

var alpha;
var beta;
var x;
var y;
var i;

for ( i = 0; i < 10; i++ ) {
x = randu();
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
y = pdf( x, alpha, beta );
console.log( 'x: %d, α: %d, β: %d, f(x;α,β): %d', x.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), y.toFixed( 4 ) );
}
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var x = uniform( 10, 0.0, 1.0, opts );

logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, f(x;α,β): %0.4f', x, alpha, beta, pdf );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pdf = require( './../lib' );

var alpha;
var beta;
var x;
var y;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var x = uniform( 10, 0.0, 1.0, opts );

for ( i = 0; i < 10; i++ ) {
x = randu();
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
y = pdf( x, alpha, beta );
console.log( 'x: %d, α: %d, β: %d, f(x;α,β): %d', x.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), y.toFixed( 4 ) );
}
logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, f(x;α,β): %0.4f', x, alpha, beta, pdf );
24 changes: 10 additions & 14 deletions lib/node_modules/@stdlib/stats/base/dists/beta/quantile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,19 @@ y = myquantile( 0.4 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var quantile = require( '@stdlib/stats/base/dists/beta/quantile' );

var alpha;
var beta;
var p;
var y;
var i;

for ( i = 0; i < 10; i++ ) {
p = randu();
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
y = quantile( p, alpha, beta );
console.log( 'p: %d, α: %d, β: %d, Q(p;α,β): %d', p.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), y.toFixed( 4 ) );
}
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var p = uniform( 10, 0.0, 1.0, opts );

logEachMap( 'p: %0.4f, α: %0.4f, β: %0.4f, Q(p;α,β): %0.4f', p, alpha, beta, quantile );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var quantile = require( './../lib' );

var alpha;
var beta;
var p;
var y;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 5.0, opts );
var beta = uniform( 10, EPS, 5.0, opts );
var p = uniform( 10, 0.0, 1.0, opts );

for ( i = 0; i < 10; i++ ) {
p = randu();
alpha = ( randu()*5.0 ) + EPS;
beta = ( randu()*5.0 ) + EPS;
y = quantile( p, alpha, beta );
console.log( 'p: %d, α: %d, β: %d, Q(p;α,β): %d', p.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), y.toFixed( 4 ) );
}
logEachMap( 'p: %0.4f, α: %0.4f, β: %0.4f, Q(p;α,β): %0.4f', p, alpha, beta, quantile );
19 changes: 8 additions & 11 deletions lib/node_modules/@stdlib/stats/base/dists/beta/skewness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,18 @@ v = skewness( 1.0, -1.0 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var skewness = require( '@stdlib/stats/base/dists/beta/skewness' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 10.0, opts );
var beta = uniform( 10, EPS, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + EPS;
beta = ( randu()*10.0 ) + EPS;
v = skewness( alpha, beta );
console.log( 'α: %d, β: %d, skew(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, skew(X;α,β): %0.4f', alpha, beta, skewness );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var skewness = require( './../lib' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 10.0, opts );
var beta = uniform( 10, EPS, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + EPS;
beta = ( randu()*10.0 ) + EPS;
v = skewness( alpha, beta );
console.log( 'α: %d, β: %d, skew(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, skew(X;α,β): %0.4f', alpha, beta, skewness );
19 changes: 8 additions & 11 deletions lib/node_modules/@stdlib/stats/base/dists/beta/stdev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,18 @@ v = stdev( 1.0, -1.0 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var stdev = require( '@stdlib/stats/base/dists/beta/stdev' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 10.0, opts );
var beta = uniform( 10, EPS, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + EPS;
beta = ( randu()*10.0 ) + EPS;
v = stdev( alpha, beta );
console.log( 'α: %d, β: %d, SD(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, SD(X;α,β): %0.4f', alpha, beta, stdev );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var stdev = require( './../lib' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 10.0, opts );
var beta = uniform( 10, EPS, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + EPS;
beta = ( randu()*10.0 ) + EPS;
v = stdev( alpha, beta );
console.log( 'α: %d, β: %d, SD(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, SD(X;α,β): %0.4f', alpha, beta, stdev );
19 changes: 8 additions & 11 deletions lib/node_modules/@stdlib/stats/base/dists/beta/variance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,18 @@ v = variance( 1.0, -1.0 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var EPS = require( '@stdlib/constants/float64/eps' );
var variance = require( '@stdlib/stats/base/dists/beta/variance' );

var alpha;
var beta;
var v;
var i;
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, EPS, 10.0, opts );
var beta = uniform( 10, EPS, 10.0, opts );

for ( i = 0; i < 10; i++ ) {
alpha = ( randu()*10.0 ) + EPS;
beta = ( randu()*10.0 ) + EPS;
v = variance( alpha, beta );
console.log( 'α: %d, β: %d, Var(X;α,β): %d', alpha.toFixed( 4 ), beta.toFixed( 4 ), v.toFixed( 4 ) );
}
logEachMap( 'α: %0.4f, β: %0.4f, Var(X;α,β): %0.4f', alpha, beta, variance );
```

</section>
Expand Down
Loading