Skip to content

Commit c642566

Browse files
committed
Use constantFunction, consolidate conditionals, abd add keywords and empty lines
1 parent 9acc445 commit c642566

4 files changed

Lines changed: 18 additions & 27 deletions

File tree

lib/node_modules/@stdlib/math/base/dist/lognormal/quantile/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// MODULES //
44

5+
var constantFunction = require( '@stdlib/utils/constant-function' );
56
var qnormal = require( '@stdlib/math/base/dist/normal/quantile' );
67
var isnan = require( '@stdlib/math/base/assert/is-nan' );
78
var exp = require( '@stdlib/math/base/special/exp' );
8-
var nan = require( './nan.js' );
99

1010

1111
// MAIN //
@@ -31,7 +31,7 @@ function factory( mu, sigma ) {
3131
isnan( sigma ) ||
3232
sigma <= 0.0
3333
) {
34-
return nan;
34+
return constantFunction( NaN );
3535
}
3636
return quantile;
3737

lib/node_modules/@stdlib/math/base/dist/lognormal/quantile/lib/nan.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/node_modules/@stdlib/math/base/dist/lognormal/quantile/lib/quantile.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,31 @@ var exp = require( '@stdlib/math/base/special/exp' );
2020
* @example
2121
* var y = quantile( 0.8, 0.0, 1.0 );
2222
* // returns ~2.32
23+
*
2324
* @example
2425
* var y = quantile( 0.5, 4.0, 2.0 );
2526
* // returns ~54.598
27+
*
2628
* @example
2729
* var y = quantile( 1.1, 0.0, 1.0 );
2830
* // returns NaN
31+
*
2932
* @example
3033
* var y = quantile( -0.2, 0.0, 1.0 );
3134
* // returns NaN
35+
*
3236
* @example
3337
* var y = quantile( NaN, 0.0, 1.0 );
3438
* // returns NaN
39+
*
3540
* @example
3641
* var y = quantile( 0.0, NaN, 1.0 );
3742
* // returns NaN
43+
*
3844
* @example
3945
* var y = quantile( 0.0, 0.0, NaN );
4046
* // returns NaN
47+
*
4148
* @example
4249
* // Negative scale parameter:
4350
* var y = quantile( 0.5, 0.0, -1.0 );
@@ -47,13 +54,13 @@ function quantile( p, mu, sigma ) {
4754
if (
4855
isnan( mu ) ||
4956
isnan( sigma ) ||
50-
sigma <= 0.0
57+
isnan( p ) ||
58+
sigma <= 0.0 ||
59+
p < 0.0 ||
60+
p > 1.0
5161
) {
5262
return NaN;
5363
}
54-
if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
55-
return NaN;
56-
}
5764
return exp( mu + (sigma * qnormal( p, 0.0, 1.0 )) );
5865
} // end FUNCTION quantile()
5966

lib/node_modules/@stdlib/math/base/dist/lognormal/quantile/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
"quantile",
3333
"gaussian",
3434
"normal",
35-
"log"
35+
"lognormal",
36+
"log",
37+
"ln",
38+
"logarithm",
39+
"natural"
3640
],
3741
"bugs": {
3842
"url": "https://github.com/stdlib-js/stdlib/issues"

0 commit comments

Comments
 (0)