diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1f61f71..d120aff71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2912,6 +2912,10 @@ A total of 17 people contributed to this release. Thank you to the following con
+- [`4a70790`](https://github.com/stdlib-js/stdlib/commit/4a707903dfef7c2b56216000165706497d19a251) - **style:** add missing spaces _(by Philipp Burckhardt)_ +- [`2965f8f`](https://github.com/stdlib-js/stdlib/commit/2965f8f4d1469ed76c7d9c150b39a87b62d73fbd) - **chore:** minor clean-up _(by Philipp Burckhardt)_ +- [`ed5c4cc`](https://github.com/stdlib-js/stdlib/commit/ed5c4cccc06ad98f4de90310bf24a5a373761b43) - **chore:** minor clean-up _(by Philipp Burckhardt)_ +- [`90e96d0`](https://github.com/stdlib-js/stdlib/commit/90e96d01b7a32ec3b71caf3e5f57528338199a8f) - **chore:** minor clean-up _(by Philipp Burckhardt)_ - [`04fda1b`](https://github.com/stdlib-js/stdlib/commit/04fda1b6f333b6ac26d2f4b65d903d25701e6877) - **refactor:** update `stats/base/dnanrange` native addon from C++ to C [(#4163)](https://github.com/stdlib-js/stdlib/pull/4163) _(by Vivek maurya)_ - [`70dde47`](https://github.com/stdlib-js/stdlib/commit/70dde4759fdc94408dc4ee058cd83e6edf6ebda7) - **refactor:** update `stats/base/dnanmeanwd` native addon from C++ to C [(#4157)](https://github.com/stdlib-js/stdlib/pull/4157) _(by Neeraj Pathak)_ - [`b7867cb`](https://github.com/stdlib-js/stdlib/commit/b7867cbb3a4fc453e19203794402c36f19b264fd) - **chore:** minor clean-up _(by Philipp Burckhardt)_ diff --git a/base/dists/bernoulli/mode/manifest.json b/base/dists/bernoulli/mode/manifest.json index 6518e2755..7b4b4c8ea 100644 --- a/base/dists/bernoulli/mode/manifest.json +++ b/base/dists/bernoulli/mode/manifest.json @@ -73,4 +73,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/base/dists/cosine/kurtosis/test/test.js b/base/dists/cosine/kurtosis/test/test.js index 002c6cf30..d3a5a0b9c 100644 --- a/base/dists/cosine/kurtosis/test/test.js +++ b/base/dists/cosine/kurtosis/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the excess kurtosis of a raised cosine distribution' s = data.s; for ( i = 0; i < mu.length; i++ ) { y = kurtosis( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/logpdf/test/test.logpdf.js b/base/dists/cosine/logpdf/test/test.logpdf.js index dd707e1ff..870523096 100644 --- a/base/dists/cosine/logpdf/test/test.logpdf.js +++ b/base/dists/cosine/logpdf/test/test.logpdf.js @@ -141,7 +141,7 @@ tape( 'the function evaluates the logpdf for `x` given positive `mu`', function s = positiveMean.s; for ( i = 0; i < x.length; i++ ) { y = logpdf( x[i], mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/mean/test/test.js b/base/dists/cosine/mean/test/test.js index 0026034dc..ec38cfcb8 100644 --- a/base/dists/cosine/mean/test/test.js +++ b/base/dists/cosine/mean/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the expected value of a raised cosine distribution', s = data.s; for ( i = 0; i < mu.length; i++ ) { y = mean( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/median/test/test.js b/base/dists/cosine/median/test/test.js index 4a2946017..4efd33fe1 100644 --- a/base/dists/cosine/median/test/test.js +++ b/base/dists/cosine/median/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the median of a raised cosine distribution', functio s = data.s; for ( i = 0; i < mu.length; i++ ) { y = median( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/mode/test/test.js b/base/dists/cosine/mode/test/test.js index 8065da6db..6ea665162 100644 --- a/base/dists/cosine/mode/test/test.js +++ b/base/dists/cosine/mode/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the mode of a raised cosine distribution', function s = data.s; for ( i = 0; i < mu.length; i++ ) { y = mode( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/quantile/test/test.quantile.js b/base/dists/cosine/quantile/test/test.quantile.js index c5d047c9b..2bd049b9b 100644 --- a/base/dists/cosine/quantile/test/test.quantile.js +++ b/base/dists/cosine/quantile/test/test.quantile.js @@ -120,7 +120,7 @@ tape( 'the function evaluates the quantile function at `p` given positive `mu`', s = positiveMean.s; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'p: '+p[i]+', mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/skewness/test/test.js b/base/dists/cosine/skewness/test/test.js index 9072db117..505cf933f 100644 --- a/base/dists/cosine/skewness/test/test.js +++ b/base/dists/cosine/skewness/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the skewness of a raised cosine distribution', funct s = data.s; for ( i = 0; i < mu.length; i++ ) { y = skewness( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/stdev/test/test.js b/base/dists/cosine/stdev/test/test.js index 611bc2120..e9f60e2a7 100644 --- a/base/dists/cosine/stdev/test/test.js +++ b/base/dists/cosine/stdev/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the standard deviation of a raised cosine distributi s = data.s; for ( i = 0; i < mu.length; i++ ) { y = stdev( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/cosine/variance/test/test.js b/base/dists/cosine/variance/test/test.js index e93386ac5..b7a6544d7 100644 --- a/base/dists/cosine/variance/test/test.js +++ b/base/dists/cosine/variance/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the variance of a raised cosine distribution', funct s = data.s; for ( i = 0; i < mu.length; i++ ) { y = variance( mu[i], s[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/exponential/mode/test/test.native.js b/base/dists/exponential/mode/test/test.native.js index c5ab9302e..c62b8611d 100644 --- a/base/dists/exponential/mode/test/test.native.js +++ b/base/dists/exponential/mode/test/test.native.js @@ -24,9 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var tryRequire = require( '@stdlib/utils/try-require' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); // VARIABLES // @@ -71,8 +69,6 @@ tape( 'if provided a rate parameter `lambda` that is not a nonnegative number, t tape( 'the function returns the mode of an exponential distribution', opts, function test( t ) { var expected; var lambda; - var delta; - var tol; var i; var y; @@ -80,13 +76,7 @@ tape( 'the function returns the mode of an exponential distribution', opts, func lambda = data.lambda; for ( i = 0; i < expected.length; i++ ) { y = mode( lambda[i] ); - if ( y === expected[ i ] ) { - t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] ); } t.end(); }); diff --git a/base/dists/f/entropy/README.md b/base/dists/f/entropy/README.md index 51965a572..e25541511 100644 --- a/base/dists/f/entropy/README.md +++ b/base/dists/f/entropy/README.md @@ -182,7 +182,7 @@ double out = stdlib_base_dists_f_entropy( 3.0, 7.0 ); The function accepts the following arguments: - **d1**: `[in] double` numerator degrees of freedom. -- **d2**: `[in] double` maximum support. +- **d2**: `[in] double` denominator degrees of freedom. ```c double stdlib_base_dists_f_entropy( const double d1, const double d2 ); diff --git a/base/dists/f/pdf/lib/ibeta_power_terms.js b/base/dists/f/pdf/lib/ibeta_power_terms.js index 68bc6667d..3308f0398 100644 --- a/base/dists/f/pdf/lib/ibeta_power_terms.js +++ b/base/dists/f/pdf/lib/ibeta_power_terms.js @@ -226,7 +226,7 @@ function ibetaPowerTerms( a, b, x, y, normalized ) { result *= pow( p1 * b2, b ); } else { l2 += l1 + ln( result ); - if (l2 >= MAX_LN) { + if ( l2 >= MAX_LN ) { return NaN; } result = exp( l2 ); diff --git a/base/dists/frechet/entropy/test/test.js b/base/dists/frechet/entropy/test/test.js index 514edcf88..19ce20a53 100644 --- a/base/dists/frechet/entropy/test/test.js +++ b/base/dists/frechet/entropy/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the differential entropy of a Fréchet distribution' s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = entropy( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/kurtosis/test/test.js b/base/dists/frechet/kurtosis/test/test.js index 101e804d6..6e953420a 100644 --- a/base/dists/frechet/kurtosis/test/test.js +++ b/base/dists/frechet/kurtosis/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the excess kurtosis of a Fréchet distribution', fun s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = kurtosis( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/mean/test/test.js b/base/dists/frechet/mean/test/test.js index f5542eb54..9f96323e2 100644 --- a/base/dists/frechet/mean/test/test.js +++ b/base/dists/frechet/mean/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the expected value of a Fréchet distribution', func s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = mean( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/median/test/test.js b/base/dists/frechet/median/test/test.js index 19493e3fe..24acba2c9 100644 --- a/base/dists/frechet/median/test/test.js +++ b/base/dists/frechet/median/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the median of a Fréchet distribution', function tes s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = median( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/mode/test/test.js b/base/dists/frechet/mode/test/test.js index cb78fb22f..acb90a3cc 100644 --- a/base/dists/frechet/mode/test/test.js +++ b/base/dists/frechet/mode/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the mode of a Fréchet distribution', function test( s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = mode( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/skewness/test/test.js b/base/dists/frechet/skewness/test/test.js index 3f4ac62c1..3e4ec59de 100644 --- a/base/dists/frechet/skewness/test/test.js +++ b/base/dists/frechet/skewness/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the skewness of a Fréchet distribution', function t s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = skewness( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/stdev/test/test.js b/base/dists/frechet/stdev/test/test.js index 7c28018ef..947c96186 100644 --- a/base/dists/frechet/stdev/test/test.js +++ b/base/dists/frechet/stdev/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the standard deviation of a Fréchet distribution', s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = stdev( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/frechet/variance/test/test.js b/base/dists/frechet/variance/test/test.js index e08e096ab..0b4385f39 100644 --- a/base/dists/frechet/variance/test/test.js +++ b/base/dists/frechet/variance/test/test.js @@ -114,7 +114,7 @@ tape( 'the function returns the variance of a Fréchet distribution', function t s = data.s; for ( i = 0; i < alpha.length; i++ ) { y = variance( alpha[i], s[i], 0.0 ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'alpha:'+alpha[i]+', s: '+s[i]+', m: 0, y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/entropy/test/test.js b/base/dists/gumbel/entropy/test/test.js index f8727a437..948cae3a2 100644 --- a/base/dists/gumbel/entropy/test/test.js +++ b/base/dists/gumbel/entropy/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the differential entropy of a Gumbel distribution', beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = entropy( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/kurtosis/test/test.js b/base/dists/gumbel/kurtosis/test/test.js index 119551de8..6ac7e51ee 100644 --- a/base/dists/gumbel/kurtosis/test/test.js +++ b/base/dists/gumbel/kurtosis/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the excess kurtosis of a Gumbel distribution', funct beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = kurtosis( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/logpdf/test/test.logpdf.js b/base/dists/gumbel/logpdf/test/test.logpdf.js index 82fe76e02..8981c41b8 100644 --- a/base/dists/gumbel/logpdf/test/test.logpdf.js +++ b/base/dists/gumbel/logpdf/test/test.logpdf.js @@ -112,7 +112,7 @@ tape( 'the function evaluates the logpdf for `x` given positive `mu`', function beta = positiveMean.beta; for ( i = 0; i < x.length; i++ ) { y = logpdf( x[i], mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/mean/test/test.js b/base/dists/gumbel/mean/test/test.js index bd55bd83e..ed35e8eb1 100644 --- a/base/dists/gumbel/mean/test/test.js +++ b/base/dists/gumbel/mean/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the mean of a Gumbel distribution', function test( t beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = mean( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/median/test/test.js b/base/dists/gumbel/median/test/test.js index d15f22605..b6ab14d87 100644 --- a/base/dists/gumbel/median/test/test.js +++ b/base/dists/gumbel/median/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the median of a Gumbel distribution', function test( beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = median( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/mode/test/test.js b/base/dists/gumbel/mode/test/test.js index a66fa5f3b..42b0ce33e 100644 --- a/base/dists/gumbel/mode/test/test.js +++ b/base/dists/gumbel/mode/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the mode of a Gumbel distribution', function test( t beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = mode( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/pdf/test/test.pdf.js b/base/dists/gumbel/pdf/test/test.pdf.js index 3744c36cd..6e4571517 100644 --- a/base/dists/gumbel/pdf/test/test.pdf.js +++ b/base/dists/gumbel/pdf/test/test.pdf.js @@ -112,7 +112,7 @@ tape( 'the function evaluates the pdf for `x` given positive `mu`', function tes beta = positiveMean.beta; for ( i = 0; i < x.length; i++ ) { y = pdf( x[i], mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/quantile/test/test.quantile.js b/base/dists/gumbel/quantile/test/test.quantile.js index f91abf9a7..74e487f64 100644 --- a/base/dists/gumbel/quantile/test/test.quantile.js +++ b/base/dists/gumbel/quantile/test/test.quantile.js @@ -108,7 +108,7 @@ tape( 'the function evaluates the quantile function at `p` given positive `mu`', beta = positiveMean.beta; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'p: '+p[i]+', mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/skewness/test/test.js b/base/dists/gumbel/skewness/test/test.js index d4b053508..9f607f939 100644 --- a/base/dists/gumbel/skewness/test/test.js +++ b/base/dists/gumbel/skewness/test/test.js @@ -72,15 +72,15 @@ tape( 'if provided a nonpositive `beta`, the function returns `NaN`', function t }); tape( 'the function returns `~1.14` as the skewness of a Gumbel distribution ', function test( t ) { - var a; - var b; + var beta; + var mu; var i; var v; for ( i = 0; i < 10; i++ ) { - a = ( randu()*10.0 ); - b = ( randu()*10.0 ) + a; - v = skewness( a, b ); + mu = ( randu()*10.0 ); + beta = ( randu()*10.0 ) + 1.0; + v = skewness( mu, beta ); t.equal( v, 1.1395470994046488, 'returns ~1.14' ); } t.end(); diff --git a/base/dists/gumbel/stdev/test/test.js b/base/dists/gumbel/stdev/test/test.js index 80d367cfb..6bf567f26 100644 --- a/base/dists/gumbel/stdev/test/test.js +++ b/base/dists/gumbel/stdev/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the standard deviation of a Gumbel distribution', fu beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = stdev( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/variance/test/test.js b/base/dists/gumbel/variance/test/test.js index a30f19932..13bb6e612 100644 --- a/base/dists/gumbel/variance/test/test.js +++ b/base/dists/gumbel/variance/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the variance of a Gumbel distribution', function tes beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = variance( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/gumbel/variance/test/test.native.js b/base/dists/gumbel/variance/test/test.native.js index d13b9e9bc..5bfbd2be3 100644 --- a/base/dists/gumbel/variance/test/test.native.js +++ b/base/dists/gumbel/variance/test/test.native.js @@ -100,7 +100,7 @@ tape( 'the function returns the variance of a Gumbel distribution', opts, functi beta = data.beta; for ( i = 0; i < mu.length; i++ ) { y = variance( mu[i], beta[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/kumaraswamy/median/README.md b/base/dists/kumaraswamy/median/README.md index 89656708e..dc749009e 100644 --- a/base/dists/kumaraswamy/median/README.md +++ b/base/dists/kumaraswamy/median/README.md @@ -171,7 +171,7 @@ for ( i = 0; i < 10; i++ ) { #### stdlib_base_dists_kumaraswamy_median( a, b ) -Evaluates the [median][median] of a [Kumaraswamy][kumaraswamy-distribution] distribution with shape parameters a and b. +Returns the [median][median] of a [Kumaraswamy's double bounded][kumaraswamy-distribution] distribution with first shape parameter `a` and second shape parameter `b`. ```c double out = stdlib_base_dists_kumaraswamy_median( 2.0, 3.0 ); @@ -180,8 +180,8 @@ double out = stdlib_base_dists_kumaraswamy_median( 2.0, 3.0 ); The function accepts the following arguments: -- **a**: `[in] double` shape parameter. -- **b**: `[in] double` shape parameter. +- **a**: `[in] double` first shape parameter. +- **b**: `[in] double` second shape parameter. ```c double stdlib_base_dists_kumaraswamy_median( const double a, const double b ); @@ -207,7 +207,6 @@ double stdlib_base_dists_kumaraswamy_median( const double a, const double b ); ```c #include "stdlib/stats/base/dists/kumaraswamy/median.h" -#include "stdlib/constants/float64/eps.h" #include #include diff --git a/base/dists/kumaraswamy/median/benchmark/benchmark.native.js b/base/dists/kumaraswamy/median/benchmark/benchmark.native.js index e7660f534..fa1fff0fa 100644 --- a/base/dists/kumaraswamy/median/benchmark/benchmark.native.js +++ b/base/dists/kumaraswamy/median/benchmark/benchmark.native.js @@ -32,9 +32,9 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var pdf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var median = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( pdf instanceof Error ) + 'skip': ( median instanceof Error ) }; @@ -57,7 +57,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = pdf( alpha[ i % len ], beta[ i % len ] ); + y = median( alpha[ i % len ], beta[ i % len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/base/dists/kumaraswamy/median/benchmark/c/Makefile b/base/dists/kumaraswamy/median/benchmark/c/Makefile index 0ebf4545e..f69e9da2b 100644 --- a/base/dists/kumaraswamy/median/benchmark/c/Makefile +++ b/base/dists/kumaraswamy/median/benchmark/c/Makefile @@ -143,4 +143,4 @@ run: $(c_targets) clean: $(QUIET) -rm -f *.o *.out -.PHONY: clean \ No newline at end of file +.PHONY: clean diff --git a/base/dists/kumaraswamy/median/benchmark/c/benchmark.c b/base/dists/kumaraswamy/median/benchmark/c/benchmark.c index 52ad75e73..72ed8634f 100644 --- a/base/dists/kumaraswamy/median/benchmark/c/benchmark.c +++ b/base/dists/kumaraswamy/median/benchmark/c/benchmark.c @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "stdlib/stats/base/dists/kumaraswamy/median.h" #include "stdlib/constants/float64/eps.h" #include diff --git a/base/dists/kumaraswamy/median/binding.gyp b/base/dists/kumaraswamy/median/binding.gyp index 507cb0029..ec3992233 100644 --- a/base/dists/kumaraswamy/median/binding.gyp +++ b/base/dists/kumaraswamy/median/binding.gyp @@ -167,4 +167,4 @@ ], # end actions }, # end target copy_addon ], # end targets -} \ No newline at end of file +} diff --git a/base/dists/kumaraswamy/median/examples/c/Makefile b/base/dists/kumaraswamy/median/examples/c/Makefile index d53ef397c..6aed70daf 100644 --- a/base/dists/kumaraswamy/median/examples/c/Makefile +++ b/base/dists/kumaraswamy/median/examples/c/Makefile @@ -143,4 +143,4 @@ run: $(c_targets) clean: $(QUIET) -rm -f *.o *.out -.PHONY: clean \ No newline at end of file +.PHONY: clean diff --git a/base/dists/kumaraswamy/median/examples/c/example.c b/base/dists/kumaraswamy/median/examples/c/example.c index 4db00037e..cda9a26ce 100644 --- a/base/dists/kumaraswamy/median/examples/c/example.c +++ b/base/dists/kumaraswamy/median/examples/c/example.c @@ -15,8 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "stdlib/stats/base/dists/kumaraswamy/median.h" -#include "stdlib/constants/float64/eps.h" #include #include @@ -32,8 +32,8 @@ int main( void ) { int i; for ( i = 0; i < 25; i++ ) { - a = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS; - b = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS; + a = random_uniform( 0.1, 10.0 ); + b = random_uniform( 0.1, 10.0 ); y = stdlib_base_dists_kumaraswamy_median( a, b ); printf( "a: %lf, b: %lf, Median(a,b): %lf\n", a, b, y ); diff --git a/base/dists/kumaraswamy/median/include.gypi b/base/dists/kumaraswamy/median/include.gypi index c6495fc1d..575cb043c 100644 --- a/base/dists/kumaraswamy/median/include.gypi +++ b/base/dists/kumaraswamy/median/include.gypi @@ -50,4 +50,4 @@ '= MAX_LN) { + if ( l2 >= MAX_LN ) { return NaN; } result = exp( l2 ); diff --git a/base/dists/negative-binomial/pmf/lib/ibeta_power_terms.js b/base/dists/negative-binomial/pmf/lib/ibeta_power_terms.js index 68bc6667d..3308f0398 100644 --- a/base/dists/negative-binomial/pmf/lib/ibeta_power_terms.js +++ b/base/dists/negative-binomial/pmf/lib/ibeta_power_terms.js @@ -226,7 +226,7 @@ function ibetaPowerTerms( a, b, x, y, normalized ) { result *= pow( p1 * b2, b ); } else { l2 += l1 + ln( result ); - if (l2 >= MAX_LN) { + if ( l2 >= MAX_LN ) { return NaN; } result = exp( l2 ); diff --git a/base/dists/normal/entropy/test/test.js b/base/dists/normal/entropy/test/test.js index 407071452..832de4f9b 100644 --- a/base/dists/normal/entropy/test/test.js +++ b/base/dists/normal/entropy/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the differential entropy of a normal distribution', sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = entropy( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/kurtosis/test/test.js b/base/dists/normal/kurtosis/test/test.js index 07802d186..9fb74c50c 100644 --- a/base/dists/normal/kurtosis/test/test.js +++ b/base/dists/normal/kurtosis/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the excess kurtosis of a normal distribution', funct sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = kurtosis( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/mean/test/test.js b/base/dists/normal/mean/test/test.js index a90de7bee..33d94ad71 100644 --- a/base/dists/normal/mean/test/test.js +++ b/base/dists/normal/mean/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the expected value of a normal distribution', functi sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = mean( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/median/test/test.js b/base/dists/normal/median/test/test.js index a2adfe5e1..232855fba 100644 --- a/base/dists/normal/median/test/test.js +++ b/base/dists/normal/median/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the median of a normal distribution', function test( sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = median( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/mgf/test/test.mgf.js b/base/dists/normal/mgf/test/test.mgf.js index f492dd700..47616ec2f 100644 --- a/base/dists/normal/mgf/test/test.mgf.js +++ b/base/dists/normal/mgf/test/test.mgf.js @@ -97,7 +97,7 @@ tape( 'the function evaluates the MGF for `x` given positive `mu`', function tes sigma = positiveLocation.sigma; for ( i = 0; i < x.length; i++ ) { y = mgf( x[i], mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/mode/test/test.js b/base/dists/normal/mode/test/test.js index c76d4f262..0db4a0baf 100644 --- a/base/dists/normal/mode/test/test.js +++ b/base/dists/normal/mode/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the mode of a normal distribution', function test( t sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = mode( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/skewness/test/test.js b/base/dists/normal/skewness/test/test.js index 01222ec9a..845323237 100644 --- a/base/dists/normal/skewness/test/test.js +++ b/base/dists/normal/skewness/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the skewness of a normal distribution', function tes sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = skewness( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/stdev/test/test.js b/base/dists/normal/stdev/test/test.js index d77d0da06..a8f32b6a0 100644 --- a/base/dists/normal/stdev/test/test.js +++ b/base/dists/normal/stdev/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the standard deviation of a normal distribution', fu sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = stdev( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/stdev/test/test.native.js b/base/dists/normal/stdev/test/test.native.js index e659b5678..7b7fa1a70 100644 --- a/base/dists/normal/stdev/test/test.native.js +++ b/base/dists/normal/stdev/test/test.native.js @@ -100,7 +100,7 @@ tape( 'the function returns the standard deviation of a normal distribution', op sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = stdev( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/normal/variance/test/test.js b/base/dists/normal/variance/test/test.js index 7a8442503..ec01fafa7 100644 --- a/base/dists/normal/variance/test/test.js +++ b/base/dists/normal/variance/test/test.js @@ -91,7 +91,7 @@ tape( 'the function returns the variance of a normal distribution', function tes sigma = data.sigma; for ( i = 0; i < mu.length; i++ ) { y = variance( mu[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'mu:'+mu[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/rayleigh/cdf/README.md b/base/dists/rayleigh/cdf/README.md index f1ea79d45..1a6d57494 100644 --- a/base/dists/rayleigh/cdf/README.md +++ b/base/dists/rayleigh/cdf/README.md @@ -215,8 +215,8 @@ static double random_uniform( const double min, const double max ) { } int main( void ) { - double x; double sigma; + double x; double y; int i; diff --git a/base/dists/rayleigh/cdf/benchmark/c/benchmark.c b/base/dists/rayleigh/cdf/benchmark/c/benchmark.c index d8e3caffd..a0dca5ffe 100644 --- a/base/dists/rayleigh/cdf/benchmark/c/benchmark.c +++ b/base/dists/rayleigh/cdf/benchmark/c/benchmark.c @@ -93,9 +93,9 @@ static double random_uniform( const double min, const double max ) { * @return elapsed time in seconds */ static double benchmark( void ) { - double elapsed; - double x[ 100 ]; double sigma[ 100 ]; + double x[ 100 ]; + double elapsed; double y; double t; int i; diff --git a/base/dists/rayleigh/cdf/src/main.c b/base/dists/rayleigh/cdf/src/main.c index 636d3ab68..f32cd0612 100644 --- a/base/dists/rayleigh/cdf/src/main.c +++ b/base/dists/rayleigh/cdf/src/main.c @@ -44,7 +44,7 @@ double stdlib_base_dists_rayleigh_cdf( const double x, const double sigma ) { if ( sigma == 0.0 ) { return ( x < 0.0 ) ? 0.0 : 1.0; } - if ( x < 0.0) { + if ( x < 0.0 ) { return 0.0; } s2 = stdlib_base_pow( sigma, 2.0 ); diff --git a/base/dists/rayleigh/logpdf/test/test.logpdf.js b/base/dists/rayleigh/logpdf/test/test.logpdf.js index ffb11d08b..34257add5 100644 --- a/base/dists/rayleigh/logpdf/test/test.logpdf.js +++ b/base/dists/rayleigh/logpdf/test/test.logpdf.js @@ -114,7 +114,7 @@ tape( 'the function evaluates the logpdf for `x` given small scale parameter `si sigma = smallScale.sigma; for ( i = 0; i < x.length; i++ ) { y = logpdf( x[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/rayleigh/pdf/test/test.native.js b/base/dists/rayleigh/pdf/test/test.native.js index 979e0a571..6c71091b7 100644 --- a/base/dists/rayleigh/pdf/test/test.native.js +++ b/base/dists/rayleigh/pdf/test/test.native.js @@ -123,7 +123,7 @@ tape( 'the function evaluates the pdf for `x` given small scale parameter `sigma sigma = smallScale.sigma; for ( i = 0; i < x.length; i++ ) { y = pdf( x[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/rayleigh/pdf/test/test.pdf.js b/base/dists/rayleigh/pdf/test/test.pdf.js index 58033a697..717e2bb74 100644 --- a/base/dists/rayleigh/pdf/test/test.pdf.js +++ b/base/dists/rayleigh/pdf/test/test.pdf.js @@ -114,7 +114,7 @@ tape( 'the function evaluates the pdf for `x` given small scale parameter `sigma sigma = smallScale.sigma; for ( i = 0; i < x.length; i++ ) { y = pdf( x[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'x: '+x[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/rayleigh/quantile/test/test.quantile.js b/base/dists/rayleigh/quantile/test/test.quantile.js index 4353e0bcb..a28511466 100644 --- a/base/dists/rayleigh/quantile/test/test.quantile.js +++ b/base/dists/rayleigh/quantile/test/test.quantile.js @@ -106,7 +106,7 @@ tape( 'the function evaluates the quantile function at `p` given small scale par sigma = smallScale.sigma; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/signrank/quantile/test/test.quantile.js b/base/dists/signrank/quantile/test/test.quantile.js index d84563063..2b4f870d9 100644 --- a/base/dists/signrank/quantile/test/test.quantile.js +++ b/base/dists/signrank/quantile/test/test.quantile.js @@ -93,7 +93,7 @@ tape( 'the function evaluates the quantile function at `p` given `n` observation n = data.n; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], n[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.equal( y, expected[i], 'p: '+p[i]+', n: '+n[i]+', y: '+y+', expected: '+expected[i] ); } else { diff --git a/base/dists/t/logpdf/README.md b/base/dists/t/logpdf/README.md index 255f2dc78..f79a93fca 100644 --- a/base/dists/t/logpdf/README.md +++ b/base/dists/t/logpdf/README.md @@ -168,9 +168,9 @@ for ( i = 0; i < 10; i++ ) { #include "stdlib/stats/base/dists/t/logpdf.h" ``` -#### stdlib_base_dists_t_logpdf( x, a, b ) +#### stdlib_base_dists_t_logpdf( x, v ) -Evaluates the natural logarithm of the [PDF][pdf] for a [Student's t][t-distribution] distribution with degree of freedom `v`. +Evaluates the natural logarithm of the [probability density function][pdf] (PDF) for a [Student's t][t-distribution] distribution with degrees of freedom `v`. ```c double out = stdlib_base_dists_t_logpdf( 0.5, 1.0 ); diff --git a/base/dists/t/logpdf/benchmark/c/benchmark.c b/base/dists/t/logpdf/benchmark/c/benchmark.c index 388552162..92c042bf6 100644 --- a/base/dists/t/logpdf/benchmark/c/benchmark.c +++ b/base/dists/t/logpdf/benchmark/c/benchmark.c @@ -16,12 +16,12 @@ * limitations under the License. */ -#include #include "stdlib/stats/base/dists/t/logpdf.h" #include #include #include #include +#include #define NAME "t-logpdf" #define ITERATIONS 1000000 diff --git a/base/dists/t/logpdf/src/main.c b/base/dists/t/logpdf/src/main.c index f724df53c..ad85b0af5 100644 --- a/base/dists/t/logpdf/src/main.c +++ b/base/dists/t/logpdf/src/main.c @@ -16,12 +16,12 @@ * limitations under the License. */ +#include "stdlib/stats/base/dists/t/logpdf.h" #include "stdlib/math/base/assert/is_nan.h" #include "stdlib/math/base/special/betaln.h" #include "stdlib/math/base/special/ln.h" #include "stdlib/math/base/special/pow.h" #include "stdlib/math/base/special/sqrt.h" -#include "stdlib/stats/base/dists/t/logpdf.h" /** * Evaluates the log probability density function (logPDF) for a Student's t distribution with degrees of freedom `v` at a value `x`. diff --git a/base/dists/t/logpdf/test/test.native.js b/base/dists/t/logpdf/test/test.native.js index 35096ce31..a4c441703 100644 --- a/base/dists/t/logpdf/test/test.native.js +++ b/base/dists/t/logpdf/test/test.native.js @@ -25,6 +25,8 @@ var tape = require( 'tape' ); var tryRequire = require( '@stdlib/utils/try-require' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); var EPS = require( '@stdlib/constants/float64/eps' ); @@ -60,19 +62,55 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f t.end(); }); -tape( 'if provided `v <= 0`, the function returns `NaN`', opts, function test( t ) { +tape( 'if provided `Infinity` for `x` and a finite `v`, the function returns `-Infinity`', opts, function test( t ) { + var y = logpdf( PINF, 1.0 ); + t.equal( y, NINF, 'returns -Infinity' ); + t.end(); +}); + +tape( 'if provided `-Infinity` for `x` and a finite `v`, the function returns `-Infinity`', opts, function test( t ) { + var y = logpdf( NINF, 1.0 ); + t.equal( y, NINF, 'returns -Infinity' ); + t.end(); +}); + +tape( 'if provided `Infinity` for `v`, the function returns `NaN`', opts, function test( t ) { var y; + y = logpdf( 0.0, PINF ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = logpdf( NaN, PINF ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = logpdf( PINF, PINF ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = logpdf( NINF, PINF ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided a nonpositive `v`, the function always returns `NaN`', opts, function test( t ) { + var y; + + y = logpdf( 2.0, 0.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = logpdf( 2.0, -1.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + y = logpdf( 0.0, -1.0 ); t.equal( isnan( y ), true, 'returns NaN' ); - y = logpdf( 0.0, 0.0 ); + y = logpdf( 2.0, NINF ); t.equal( isnan( y ), true, 'returns NaN' ); t.end(); }); -tape( 'the function evaluates the logpdf for `x` given a large range of `v` and `x`', opts, function test( t ) { +tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` and `v` are small)', opts, function test( t ) { var expected; var delta; var tol; @@ -81,26 +119,23 @@ tape( 'the function evaluates the logpdf for `x` given a large range of `v` and var y; var i; - expected = largeLarge.expected; - x = largeLarge.x; - v = largeLarge.v; + expected = smallSmall.expected; + x = smallSmall.x; + v = smallSmall.v; for ( i = 0; i < x.length; i++ ) { - y = logpdf( x[ i ], v[ i ] ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] ); + y = logpdf( x[i], v[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] ); } else { delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - if ( tol < 1e-14 ) { - tol = 1e-14; // Set a minimum tolerance - } - t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + tol = 10.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); } } t.end(); }); -tape( 'the function evaluates the logpdf for `x` given a large range of `v` and small range of `x`', opts, function test( t ) { +tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` is large and `v` small)', opts, function test( t ) { var expected; var delta; var tol; @@ -113,22 +148,19 @@ tape( 'the function evaluates the logpdf for `x` given a large range of `v` and x = largeSmall.x; v = largeSmall.v; for ( i = 0; i < x.length; i++ ) { - y = logpdf( x[ i ], v[ i ] ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] ); + y = logpdf( x[i], v[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] ); } else { delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - if ( tol < 1e-14 ) { - tol = 1e-14; // Set a minimum tolerance - } - t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + tol = 10.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); } } t.end(); }); -tape( 'the function evaluates the logpdf for `x` given a small range of `v` and large range of `x`', opts, function test( t ) { +tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` is small and `v` large)', opts, function test( t ) { var expected; var delta; var tol; @@ -141,22 +173,19 @@ tape( 'the function evaluates the logpdf for `x` given a small range of `v` and x = smallLarge.x; v = smallLarge.v; for ( i = 0; i < x.length; i++ ) { - y = logpdf( x[ i ], v[ i ] ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] ); + y = logpdf( x[i], v[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] ); } else { delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - if ( tol < 1e-14 ) { - tol = 1e-14; // Set a minimum tolerance - } - t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + tol = 50.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); } } t.end(); }); -tape( 'the function evaluates the logpdf for `x` given a small range of `v` and `x`', opts, function test( t ) { +tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` and `v` are large)', opts, function test( t ) { var expected; var delta; var tol; @@ -165,20 +194,17 @@ tape( 'the function evaluates the logpdf for `x` given a small range of `v` and var y; var i; - expected = smallSmall.expected; - x = smallSmall.x; - v = smallSmall.v; + expected = largeLarge.expected; + x = largeLarge.x; + v = largeLarge.v; for ( i = 0; i < x.length; i++ ) { - y = logpdf( x[ i ], v[ i ] ); - if ( y === expected[ i ] ) { - t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] ); + y = logpdf( x[i], v[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] ); } else { delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - if ( tol < 1e-14 ) { - tol = 1e-14; // Set a minimum tolerance - } - t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + tol = 40.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); } } t.end(); diff --git a/kde2d/examples/index.js b/kde2d/examples/index.js index c8f764a43..f8f673202 100644 --- a/kde2d/examples/index.js +++ b/kde2d/examples/index.js @@ -44,7 +44,7 @@ y = new Array( n ); randX = normal.factory( 3, 1.2 ); randY = normal.factory( 10, 4.5 ); -for (i = 0; i < n; i++) { +for ( i = 0; i < n; i++ ) { x[ i ] = randX(); y[ i ] = randY(); } diff --git a/kde2d/lib/cosine.js b/kde2d/lib/cosine.js index 26e99cced..76c52f78c 100644 --- a/kde2d/lib/cosine.js +++ b/kde2d/lib/cosine.js @@ -41,7 +41,7 @@ var cos = require( '@stdlib/math/base/special/cos' ); * var out = cosine( u ); * // returns 0.0 */ -function cosine(u) { +function cosine( u ) { if ( isnan( u ) ) { return NaN; } diff --git a/kde2d/lib/epanechnikov.js b/kde2d/lib/epanechnikov.js index 12ba4920d..0452e0e8e 100644 --- a/kde2d/lib/epanechnikov.js +++ b/kde2d/lib/epanechnikov.js @@ -39,7 +39,7 @@ var pow = require( '@stdlib/math/base/special/pow' ); * var out = epanechnikov( u ); * // returns 0.0 */ -function epanechnikov(u) { +function epanechnikov( u ) { if ( isnan( u ) ) { return NaN; } diff --git a/kde2d/lib/tricube.js b/kde2d/lib/tricube.js index 8d9c7f31a..10f90f0c1 100644 --- a/kde2d/lib/tricube.js +++ b/kde2d/lib/tricube.js @@ -44,7 +44,7 @@ var LEADING_TERM = ( 70.0 / 81.0 ); * out = tricube(u); * // returns 0.0 */ -function tricube(u) { +function tricube( u ) { var absU; if ( isnan( u ) ) { diff --git a/kde2d/lib/uniform.js b/kde2d/lib/uniform.js index fa83e3776..b7d07fab8 100644 --- a/kde2d/lib/uniform.js +++ b/kde2d/lib/uniform.js @@ -37,7 +37,7 @@ var isnan = require( '@stdlib/assert/is-nan' ); * var out = uniform( u ); * // returns 0.5 */ -function uniform(u) { +function uniform( u ) { if ( isnan( u ) ) { return NaN; } diff --git a/kde2d/test/test.js b/kde2d/test/test.js index 2c569af6b..3b42d0dbd 100644 --- a/kde2d/test/test.js +++ b/kde2d/test/test.js @@ -214,18 +214,18 @@ tape( 'the function computes the same values with `ndarray` and numeric array in actualNumeric = kde2d( dataXSmall, dataYSmall ); // Check x - for (i = 0; i < n; i++) { + for ( i = 0; i < n; i++ ) { t.equal(actualND.x[i], actualNumeric.x[i], 'xND: '+actualND.x[i]+', xNumeric: '+actualNumeric.x[i]); } // Check y - for (i = 0; i < n; i++) { + for ( i = 0; i < n; i++ ) { t.equal(actualND.y[i], actualNumeric.y[i], 'yND: '+actualND.y[i]+', yNumeric: '+actualNumeric.y[i]); } // Check z - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { + for ( i = 0; i < n; i++ ) { + for ( j = 0; j < n; j++ ) { t.equal(actualND.z.get(i, j), actualNumeric.z.get(i, j), 'zND: '+actualND.z.get(i, j)+', zNumeric: '+actualNumeric.z.get(i, j)); } } @@ -243,7 +243,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a small data actual = kde2d(dataXSmall, dataYSmall); // Check x - for (i = 0; i < actual.x.length; i++) { + for ( i = 0; i < actual.x.length; i++ ) { if ( actual.x[i] === expectedSmall.x[i] ) { t.equal( actual.x[i], expectedSmall.x[i], 'x: '+actual.x[i]+', expected: '+expectedSmall.x[i] ); } else { @@ -254,7 +254,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a small data } // Check y - for (i = 0; i < actual.y.length; i++) { + for ( i = 0; i < actual.y.length; i++ ) { if ( actual.y[i] === expectedSmall.y[i] ) { t.equal( actual.y[i], expectedSmall.y[i], 'x: '+actual.y[i]+', expected: '+expectedSmall.y[i] ); } else { @@ -265,8 +265,8 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a small data } // Check z - for (i = 0; i < actual.x.length; i++) { - for (j = 0; j < actual.y.length; j++) { + for ( i = 0; i < actual.x.length; i++ ) { + for ( j = 0; j < actual.y.length; j++ ) { if ( actual.z.get(i, j) === expectedSmall.z[i][j] ) { t.equal( actual.z.get(i, j), expectedSmall.z[i][j], 'z: '+actual.z.get(i, j)+', expected: '+expectedSmall.z[i][j] ); } else { @@ -290,7 +290,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a medium dat actual = kde2d(dataX, dataY); // Check x - for (i = 0; i < actual.x.length; i++) { + for ( i = 0; i < actual.x.length; i++ ) { if ( actual.x[i] === expected.x[i] ) { t.equal( actual.x[i], expected.x[i], 'x: '+actual.x[i]+', expected: '+expected.x[i] ); } else { @@ -301,7 +301,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a medium dat } // Check y - for (i = 0; i < actual.y.length; i++) { + for ( i = 0; i < actual.y.length; i++ ) { if ( actual.y[i] === expected.y[i] ) { t.equal( actual.y[i], expected.y[i], 'x: '+actual.y[i]+', expected: '+expected.y[i] ); } else { @@ -312,8 +312,8 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a medium dat } // Check z - for (i = 0; i < actual.x.length; i++) { - for (j = 0; j < actual.y.length; j++) { + for ( i = 0; i < actual.x.length; i++ ) { + for ( j = 0; j < actual.y.length; j++ ) { if ( actual.z.get(i, j) === expected.z[i][j] ) { t.equal( actual.z.get(i, j), expected.z[i][j], 'z: '+actual.z.get(i, j)+', expected: '+expected.z[i][j] ); } else { @@ -337,7 +337,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a large data actual = kde2d(dataX2, dataY2); // Check x - for (i = 0; i < actual.x.length; i++) { + for ( i = 0; i < actual.x.length; i++ ) { if ( actual.x[i] === expected2.x[i] ) { t.equal( actual.x[i], expected2.x[i], 'x: '+actual.x[i]+', expected2: '+expected2.x[i] ); } else { @@ -348,7 +348,7 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a large data } // Check y - for (i = 0; i < actual.y.length; i++) { + for ( i = 0; i < actual.y.length; i++ ) { if ( actual.y[i] === expected2.y[i] ) { t.equal( actual.y[i], expected2.y[i], 'x: '+actual.y[i]+', expected2: '+expected2.y[i] ); } else { @@ -359,8 +359,8 @@ tape( 'the function correctly computes 2 dimensional normal KDE for a large data } // Check z - for (i = 0; i < actual.x.length; i++) { - for (j = 0; j < actual.y.length; j++) { + for ( i = 0; i < actual.x.length; i++ ) { + for ( j = 0; j < actual.y.length; j++ ) { if ( actual.z.get(i, j) === expected2.z[i][j] ) { t.equal( actual.z.get(i, j), expected2.z[i][j], 'z: '+actual.z.get(i, j)+', expected2: '+expected2.z[i][j] ); } else { diff --git a/kstest/lib/marsaglia.js b/kstest/lib/marsaglia.js index a0470baee..1ab0a05d0 100644 --- a/kstest/lib/marsaglia.js +++ b/kstest/lib/marsaglia.js @@ -155,7 +155,7 @@ function pKolmogorov( d, n ) { var z; z = new Float64Array( m * m ); - for ( i = 0; i < m; i++) { + for ( i = 0; i < m; i++ ) { for ( j = 0; j < m; j++ ) { s = 0; for ( k = 0; k < m; k++ ) {