-
-
Notifications
You must be signed in to change notification settings - Fork 906
docs: replace manual for
loop in examples
#6249
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,19 +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 logcdf = require( './../lib' ); | ||
|
||
var a; | ||
var b; | ||
var x; | ||
var y; | ||
var i; | ||
var opts = { | ||
'dtype': 'float64' | ||
}; | ||
var x = uniform( 25, -10.0, 10.0, opts ); | ||
var a = uniform( x.length, -20.0, 0.0, opts ); | ||
var b = uniform( x.length, 0.0, 40.0, opts ); | ||
|
||
for ( i = 0; i < 25; i++ ) { | ||
x = ( randu()*20.0 ) - 10.0; | ||
a = ( randu()*20.0 ) - 20.0; | ||
b = a + ( randu()*40.0 ); | ||
y = logcdf( x, a, b ); | ||
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 ) ); | ||
} | ||
logEachMap( 'x: %d, a: %d, b: %d, ln(F(x;a,b)): %d', x, a, b, logcdf ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,22 +125,18 @@ y = mylogPDF( 5.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 logpdf = require( '@stdlib/stats/base/dists/arcsine/logpdf' ); | ||
|
||
var a; | ||
var b; | ||
var x; | ||
var y; | ||
var i; | ||
|
||
for ( i = 0; i < 25; i++ ) { | ||
x = ( randu()*20.0 ) - 10.0; | ||
a = ( randu()*20.0 ) - 20.0; | ||
b = a + ( randu()*40.0 ); | ||
y = logpdf( x, a, b ); | ||
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 ) ); | ||
} | ||
var opts = { | ||
'dtype': 'float64' | ||
}; | ||
var x = uniform( 25, -10.0, 10.0, opts ); | ||
var a = uniform( x.length, -20.0, 0.0, opts ); | ||
var b = uniform( x.length, 0.0, 40.0, opts ); | ||
|
||
logEachMap( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x, a, b, logpdf ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
``` | ||
|
||
</section> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,19 +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 logpdf = require( './../lib' ); | ||
|
||
var a; | ||
var b; | ||
var x; | ||
var y; | ||
var i; | ||
var opts = { | ||
'dtype': 'float64' | ||
}; | ||
var x = uniform( 25, -10.0, 10.0, opts ); | ||
var a = uniform( x.length, -20.0, 0.0, opts ); | ||
var b = uniform( x.length, 0.0, 40.0, opts ); | ||
|
||
for ( i = 0; i < 25; i++ ) { | ||
x = ( randu()*20.0 ) - 10.0; | ||
a = ( randu()*20.0 ) - 20.0; | ||
b = a + ( randu()*40.0 ); | ||
y = logpdf( x, a, b ); | ||
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 ) ); | ||
} | ||
logEachMap( 'x: %d, a: %d, b: %d, ln(f(x;a,b)): %d', x, a, b, logpdf ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anandkaranubc These should be
%0.4f
. This applies to other packages, as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Planeshifter
logEachMap
supportsstring/format
string interpolation.