Skip to content

Commit 6ff59dd

Browse files
docs: replace manual for loop in examples
PR-URL: #6249 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 15e183d commit 6ff59dd

File tree

24 files changed

+205
-287
lines changed

24 files changed

+205
-287
lines changed

lib/node_modules/@stdlib/stats/base/dists/arcsine/entropy/README.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,17 @@ y = entropy( 3.0, 3.0 );
111111
<!-- eslint no-undef: "error" -->
112112

113113
```javascript
114-
var randu = require( '@stdlib/random/base/randu' );
115-
var EPS = require( '@stdlib/constants/float64/eps' );
114+
var uniform = require( '@stdlib/random/array/uniform' );
115+
var logEachMap = require( '@stdlib/console/log-each-map' );
116116
var entropy = require( '@stdlib/stats/base/dists/arcsine/entropy' );
117117

118-
var a;
119-
var b;
120-
var v;
121-
var i;
118+
var opts = {
119+
'dtype': 'float64'
120+
};
121+
var a = uniform( 25, 0.0, 10.0, opts );
122+
var b = uniform( a.length, 15.0, 25.0, opts );
122123

123-
for ( i = 0; i < 10; i++ ) {
124-
a = ( randu()*10.0 );
125-
b = ( randu()*10.0 ) + a + EPS;
126-
v = entropy( a, b );
127-
console.log( 'a: %d, b: %d, h(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
128-
}
124+
logEachMap( 'a: %0.4f, b: %0.4f, h(X;a,b): %0.4f', a, b, entropy );
129125
```
130126

131127
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/entropy/examples/index.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var EPS = require( '@stdlib/constants/float64/eps' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var entropy = require( './../lib' );
2424

25-
var a;
26-
var b;
27-
var v;
28-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var a = uniform( 25, 0.0, 10.0, opts );
29+
var b = uniform( a.length, 15.0, 25.0, opts );
2930

30-
for ( i = 0; i < 10; i++ ) {
31-
a = ( randu()*10.0 );
32-
b = ( randu()*10.0 ) + a + EPS;
33-
v = entropy( a, b );
34-
console.log( 'a: %d, b: %d, h(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
35-
}
31+
logEachMap( 'a: %0.4f, b: %0.4f, h(X;a,b): %0.4f', a, b, entropy );

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,17 @@ y = kurtosis( 3.0, 3.0 );
111111
<!-- eslint no-undef: "error" -->
112112

113113
```javascript
114-
var randu = require( '@stdlib/random/base/randu' );
114+
var uniform = require( '@stdlib/random/array/uniform' );
115+
var logEachMap = require( '@stdlib/console/log-each-map' );
115116
var kurtosis = require( '@stdlib/stats/base/dists/arcsine/kurtosis' );
116117

117-
var a;
118-
var b;
119-
var v;
120-
var i;
118+
var opts = {
119+
'dtype': 'float64'
120+
};
121+
var a = uniform( 25, 0.0, 10.0, opts );
122+
var b = uniform( a.length, 10.0, 20.0, opts );
121123

122-
for ( i = 0; i < 10; i++ ) {
123-
a = ( randu()*10.0 );
124-
b = ( randu()*10.0 ) + a;
125-
v = kurtosis( a, b );
126-
console.log( 'a: %d, b: %d, Kurt(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
127-
}
124+
logEachMap( 'a: %0.4f, b: %0.4f, Kurt(X;a,b): %0.4f', a, b, kurtosis );
128125
```
129126

130127
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/examples/index.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var kurtosis = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var v;
27-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var a = uniform( 25, 0.0, 10.0, opts );
29+
var b = uniform( a.length, 10.0, 20.0, opts );
2830

29-
for ( i = 0; i < 10; i++ ) {
30-
a = ( randu()*10.0 );
31-
b = ( randu()*10.0 ) + a;
32-
v = kurtosis( a, b );
33-
console.log( 'a: %d, b: %d, Kurt(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
34-
}
31+
logEachMap( 'a: %0.4f, b: %0.4f, Kurt(X;a,b): %0.4f', a, b, kurtosis );

lib/node_modules/@stdlib/stats/base/dists/arcsine/logcdf/README.md

+10-14
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,18 @@ y = mylogcdf( 8.0 );
125125
<!-- eslint no-undef: "error" -->
126126

127127
```javascript
128-
var randu = require( '@stdlib/random/base/randu' );
128+
var uniform = require( '@stdlib/random/array/uniform' );
129+
var logEachMap = require( '@stdlib/console/log-each-map' );
129130
var logcdf = require( '@stdlib/stats/base/dists/arcsine/logcdf' );
130131

131-
var a;
132-
var b;
133-
var x;
134-
var y;
135-
var i;
136-
137-
for ( i = 0; i < 25; i++ ) {
138-
x = ( randu()*20.0 ) - 10.0;
139-
a = ( randu()*20.0 ) - 20.0;
140-
b = a + ( randu()*40.0 );
141-
y = logcdf( x, a, b );
142-
console.log( 'x: %d, a: %d, b: %d, ln(F(x;a,b)): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
143-
}
132+
var opts = {
133+
'dtype': 'float64'
134+
};
135+
var x = uniform( 25, -10.0, 10.0, opts );
136+
var a = uniform( x.length, -20.0, 0.0, opts );
137+
var b = uniform( x.length, 0.0, 40.0, opts );
138+
139+
logEachMap( 'x: %d, a: %d, b: %d, ln(F(x;a,b)): %d', x, a, b, logcdf );
144140
```
145141

146142
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/logcdf/examples/index.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var logcdf = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var x;
27-
var y;
28-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 25, -10.0, 10.0, opts );
29+
var a = uniform( x.length, -20.0, 0.0, opts );
30+
var b = uniform( x.length, 0.0, 40.0, opts );
2931

30-
for ( i = 0; i < 25; i++ ) {
31-
x = ( randu()*20.0 ) - 10.0;
32-
a = ( randu()*20.0 ) - 20.0;
33-
b = a + ( randu()*40.0 );
34-
y = logcdf( x, a, b );
35-
console.log( 'x: %d, a: %d, b: %d, ln(F(x;a,b)): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
36-
}
32+
logEachMap( 'x: %d, a: %d, b: %d, ln(F(x;a,b)): %d', x, a, b, logcdf );

lib/node_modules/@stdlib/stats/base/dists/arcsine/logpdf/README.md

+10-14
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,18 @@ y = mylogPDF( 5.0 );
125125
<!-- eslint no-undef: "error" -->
126126

127127
```javascript
128-
var randu = require( '@stdlib/random/base/randu' );
128+
var uniform = require( '@stdlib/random/array/uniform' );
129+
var logEachMap = require( '@stdlib/console/log-each-map' );
129130
var logpdf = require( '@stdlib/stats/base/dists/arcsine/logpdf' );
130131

131-
var a;
132-
var b;
133-
var x;
134-
var y;
135-
var i;
136-
137-
for ( i = 0; i < 25; i++ ) {
138-
x = ( randu()*20.0 ) - 10.0;
139-
a = ( randu()*20.0 ) - 20.0;
140-
b = a + ( randu()*40.0 );
141-
y = logpdf( x, a, b );
142-
console.log( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
143-
}
132+
var opts = {
133+
'dtype': 'float64'
134+
};
135+
var x = uniform( 25, -10.0, 10.0, opts );
136+
var a = uniform( x.length, -20.0, 0.0, opts );
137+
var b = uniform( x.length, 0.0, 40.0, opts );
138+
139+
logEachMap( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x, a, b, logpdf );
144140
```
145141

146142
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/logpdf/examples/index.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var logpdf = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var x;
27-
var y;
28-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 25, -10.0, 10.0, opts );
29+
var a = uniform( x.length, -20.0, 0.0, opts );
30+
var b = uniform( x.length, 0.0, 40.0, opts );
2931

30-
for ( i = 0; i < 25; i++ ) {
31-
x = ( randu()*20.0 ) - 10.0;
32-
a = ( randu()*20.0 ) - 20.0;
33-
b = a + ( randu()*40.0 );
34-
y = logpdf( x, a, b );
35-
console.log( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
36-
}
32+
logEachMap( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x, a, b, logpdf );

lib/node_modules/@stdlib/stats/base/dists/arcsine/mean/README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,17 @@ y = mean( 3.0, 3.0 );
113113
<!-- eslint no-undef: "error" -->
114114

115115
```javascript
116-
var randu = require( '@stdlib/random/base/randu' );
116+
var uniform = require( '@stdlib/random/array/uniform' );
117+
var logEachMap = require( '@stdlib/console/log-each-map' );
117118
var mean = require( '@stdlib/stats/base/dists/arcsine/mean' );
118119

119-
var a;
120-
var b;
121-
var v;
122-
var i;
120+
var opts = {
121+
'dtype': 'float64'
122+
};
123+
var a = uniform( 25, 0.0, 10.0, opts );
124+
var b = uniform( a.length, 10.0, 20.0, opts );
123125

124-
for ( i = 0; i < 10; i++ ) {
125-
a = ( randu()*10.0 );
126-
b = ( randu()*10.0 ) + a;
127-
v = mean( a, b );
128-
console.log( 'a: %d, b: %d, E(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
129-
}
126+
logEachMap( 'a: %0.4f, b: %0.4f, E(X;a,b): %0.4f', a, b, mean );
130127
```
131128

132129
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/mean/examples/index.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var mean = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var v;
27-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var a = uniform( 25, 0.0, 10.0, opts );
29+
var b = uniform( a.length, 10.0, 20.0, opts );
2830

29-
for ( i = 0; i < 10; i++ ) {
30-
a = ( randu()*10.0 );
31-
b = ( randu()*10.0 ) + a;
32-
v = mean( a, b );
33-
console.log( 'a: %d, b: %d, E(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
34-
}
31+
logEachMap( 'a: %0.4f, b: %0.4f, E(X;a,b): %0.4f', a, b, mean );

lib/node_modules/@stdlib/stats/base/dists/arcsine/median/README.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,17 @@ y = median( 3.0, 3.0 );
113113
<!-- eslint no-undef: "error" -->
114114

115115
```javascript
116-
var randu = require( '@stdlib/random/base/randu' );
116+
var uniform = require( '@stdlib/random/array/uniform' );
117+
var logEachMap = require( '@stdlib/console/log-each-map' );
117118
var median = require( '@stdlib/stats/base/dists/arcsine/median' );
118119

119-
var a;
120-
var b;
121-
var v;
122-
var i;
123-
124-
for ( i = 0; i < 10; i++ ) {
125-
a = ( randu()*10.0 );
126-
b = ( randu()*10.0 ) + a;
127-
v = median( a, b );
128-
console.log( 'a: %d, b: %d, Median(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
129-
}
120+
var opts = {
121+
'dtype': 'float64'
122+
};
123+
var a = uniform( 25, 0.0, 10.0, opts );
124+
var b = uniform( a.length, 10.0, 20.0, opts );
125+
126+
logEachMap( 'a: %0.4f, b: %0.4f, Median(X;a,b): %0.4f', a, b, median );
130127
```
131128

132129
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/median/examples/index.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var median = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var v;
27-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var a = uniform( 25, 0.0, 10.0, opts );
29+
var b = uniform( a.length, 10.0, 20.0, opts );
2830

29-
for ( i = 0; i < 10; i++ ) {
30-
a = ( randu()*10.0 );
31-
b = ( randu()*10.0 ) + a;
32-
v = median( a, b );
33-
console.log( 'a: %d, b: %d, Median(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
34-
}
31+
logEachMap( 'a: %0.4f, b: %0.4f, Median(X;a,b): %0.4f', a, b, median );

lib/node_modules/@stdlib/stats/base/dists/arcsine/mode/README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,17 @@ y = mode( 3.0, 3.0 );
111111
<!-- eslint no-undef: "error" -->
112112

113113
```javascript
114-
var randu = require( '@stdlib/random/base/randu' );
114+
var uniform = require( '@stdlib/random/array/uniform' );
115+
var logEachMap = require( '@stdlib/console/log-each-map' );
115116
var mode = require( '@stdlib/stats/base/dists/arcsine/mode' );
116117

117-
var a;
118-
var b;
119-
var v;
120-
var i;
118+
var opts = {
119+
'dtype': 'float64'
120+
};
121+
var a = uniform( 25, 0.0, 10.0, opts );
122+
var b = uniform( a.length, 10.0, 20.0, opts );
121123

122-
for ( i = 0; i < 10; i++ ) {
123-
a = ( randu()*10.0 );
124-
b = ( randu()*10.0 ) + a;
125-
v = mode( a, b );
126-
console.log( 'a: %d, b: %d, mode(X;a,b): %d', a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
127-
}
124+
logEachMap( 'a: %0.4f, b: %0.4f, mode(X;a,b): %0.4f', a, b, mode );
128125
```
129126

130127
</section>

0 commit comments

Comments
 (0)