Skip to content

Commit

Permalink
chore: address commit comments and use discrete uniform PRNG
Browse files Browse the repository at this point in the history
PR-URL: #5313
Closes: #5303

Reviewed-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Karan Anand <[email protected]>
Signed-off-by: Rishav Tarway <[email protected]>
  • Loading branch information
rishavtarway authored Feb 22, 2025
1 parent a721643 commit 6670680
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Returns the [median][median] of a [binomial][binomial-distribution] distribution

```c
double out = stdlib_base_dists_binomial_median( 100, 0.1 );
// returns 10
// returns 10.0
```

The function accepts the following arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var Int32Array = require( '@stdlib/array/int32' );
var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var ceil = require( '@stdlib/math/base/special/ceil' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;

Expand All @@ -49,11 +48,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var i;

len = 100;
n = new Int32Array( len );
n = new Float64Array( len );
p = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
n[ i ] = ceil( randu() * 100.0 );
p[ i ] = randu();
n[ i ] = discreteUniform( 1, 100 );
p[ i ] = uniform( 0.0, 1.0 );
}

b.tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @example
* double y = stdlib_base_dists_binomial_median( 100, 0.1 );
* // returns 10
* // returns 10.0
*/
double stdlib_base_dists_binomial_median( const int32_t n, const double p ) {
if (
Expand Down

1 comment on commit 6670680

@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/dists/binomial/median $\color{green}178/178$
$\color{green}+100.00\%$
$\color{green}12/12$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}178/178$
$\color{green}+100.00\%$

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

Please sign in to comment.