@stdlib/stats-base-dists-wald-pdf 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +376 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +124 -0
- package/include/stdlib/stats/base/dists/wald/pdf.h +38 -0
- package/lib/factory.js +93 -0
- package/lib/index.js +51 -0
- package/lib/main.js +120 -0
- package/lib/native.js +96 -0
- package/manifest.json +93 -0
- package/package.json +83 -0
- package/src/addon.c +22 -0
- package/src/main.c +62 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Evaluates the probability density function (PDF) for a Wald distribution.
|
|
23
|
+
*
|
|
24
|
+
* @param x - input value
|
|
25
|
+
* @returns evaluated PDF
|
|
26
|
+
*/
|
|
27
|
+
type Unary = ( x: number ) => number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Interface for the probability density function (PDF) of a Wald distribution.
|
|
31
|
+
*/
|
|
32
|
+
interface PDF {
|
|
33
|
+
/**
|
|
34
|
+
* Evaluates the probability density function (PDF) for a Wald distribution with mean `mu` and shape parameter `lambda` at a value `x`.
|
|
35
|
+
*
|
|
36
|
+
* ## Notes
|
|
37
|
+
*
|
|
38
|
+
* - If provided `mu <= 0` or `lambda < 0`, the function returns `NaN`.
|
|
39
|
+
*
|
|
40
|
+
* @param x - input value
|
|
41
|
+
* @param mu - mean parameter
|
|
42
|
+
* @param lambda - shape parameter
|
|
43
|
+
* @returns evaluated probability density function
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = pdf( 2.0, 1.0, 1.0 );
|
|
47
|
+
* // returns ~0.110
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = pdf( 5.0, 3.0, 2.0 );
|
|
51
|
+
* // returns ~0.046
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = pdf( NaN, 1.0, 1.0 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = pdf( 2.0, NaN, 1.0 );
|
|
59
|
+
* // returns NaN
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = pdf( 2.0, 1.0, NaN );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Non-positive mean:
|
|
67
|
+
* var y = pdf( 2.0, 0.0, 1.0 );
|
|
68
|
+
* // returns NaN
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Negative shape parameter:
|
|
72
|
+
* var y = pdf( 2.0, 1.0, -1.0 );
|
|
73
|
+
* // returns NaN
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* var y = pdf( 2.0, 1.0, 0.0 );
|
|
77
|
+
* // returns 0.0
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* var y = pdf( 1.0, 1.0, 0.0 );
|
|
81
|
+
* // returns Infinity
|
|
82
|
+
*/
|
|
83
|
+
( x: number, mu: number, lambda: number ): number;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns a function for evaluating the probability density function (PDF) for a Wald distribution.
|
|
87
|
+
*
|
|
88
|
+
* @param mu - mean parameter
|
|
89
|
+
* @param lambda - shape parameter
|
|
90
|
+
* @returns function to evaluate the probability density function
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* var myPDF = pdf.factory( 3.0, 2.0 );
|
|
94
|
+
* var y = myPDF( 2.0 );
|
|
95
|
+
* // returns ~0.189
|
|
96
|
+
*
|
|
97
|
+
* y = myPDF( 5.0 );
|
|
98
|
+
* // returns ~0.046
|
|
99
|
+
*/
|
|
100
|
+
factory( mu: number, lambda: number ): Unary;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Wald distribution probability density function (PDF).
|
|
105
|
+
*
|
|
106
|
+
* @param x - input value
|
|
107
|
+
* @param mu - mean parameter
|
|
108
|
+
* @param lambda - shape parameter
|
|
109
|
+
* @returns evaluated PDF
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* var y = pdf( 2.0, 1.0, 1.0 );
|
|
113
|
+
* // returns ~0.110
|
|
114
|
+
*
|
|
115
|
+
* var myPDF = pdf.factory( 3.0, 2.0 );
|
|
116
|
+
* y = myPDF( 2.0 );
|
|
117
|
+
* // returns ~0.189
|
|
118
|
+
*/
|
|
119
|
+
declare var pdf: PDF;
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// EXPORTS //
|
|
123
|
+
|
|
124
|
+
export = pdf;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_STATS_BASE_DISTS_WALD_PDF_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_WALD_PDF_H
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
24
|
+
*/
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Evaluates the probability density function (PDF) for a Wald distribution with mean `mu` and shape parameter `lambda` at a value `x`.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_wald_pdf( const double x, const double mu, const double lambda );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_WALD_PDF_H
|
package/lib/factory.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var constantFunction = require( '@stdlib/utils-constant-function' );
|
|
24
|
+
var degenerate = require( '@stdlib/stats-base-dists-degenerate-pdf' ).factory;
|
|
25
|
+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
26
|
+
var sqrt = require( '@stdlib/math-base-special-sqrt' );
|
|
27
|
+
var exp = require( '@stdlib/math-base-special-exp' );
|
|
28
|
+
var TWO_PI = require( '@stdlib/constants-float64-two-pi' );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// MAIN //
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns a function for evaluating the probability density function (PDF) for a Wald distribution.
|
|
35
|
+
*
|
|
36
|
+
* @param {PositiveNumber} mu - mean
|
|
37
|
+
* @param {PositiveNumber} lambda - shape parameter
|
|
38
|
+
* @returns {Function} function to evaluate the probability density function
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var pdf = factory( 1.0, 1.0 );
|
|
42
|
+
* var y = pdf( 2.0 );
|
|
43
|
+
* // returns ~0.110
|
|
44
|
+
*
|
|
45
|
+
* y = pdf( 0.5 );
|
|
46
|
+
* // returns ~0.879
|
|
47
|
+
*/
|
|
48
|
+
function factory( mu, lambda ) {
|
|
49
|
+
var A;
|
|
50
|
+
var B;
|
|
51
|
+
if (
|
|
52
|
+
isnan( mu ) ||
|
|
53
|
+
isnan( lambda ) ||
|
|
54
|
+
mu <= 0.0 ||
|
|
55
|
+
lambda < 0.0
|
|
56
|
+
) {
|
|
57
|
+
return constantFunction( NaN );
|
|
58
|
+
}
|
|
59
|
+
if ( lambda === 0.0 ) {
|
|
60
|
+
return degenerate( mu );
|
|
61
|
+
}
|
|
62
|
+
A = sqrt( lambda / TWO_PI );
|
|
63
|
+
B = -lambda / ( 2.0 * mu * mu );
|
|
64
|
+
return pdf;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Evaluates the probability density function (PDF) for a Wald distribution.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
* @param {number} x - input value
|
|
71
|
+
* @returns {number} evaluated probability density function
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* var y = pdf( 2.0 );
|
|
75
|
+
* // returns <number>
|
|
76
|
+
*/
|
|
77
|
+
function pdf( x ) {
|
|
78
|
+
var v;
|
|
79
|
+
if ( isnan( x ) ) {
|
|
80
|
+
return NaN;
|
|
81
|
+
}
|
|
82
|
+
if ( x <= 0.0 || !isFinite( x ) ) {
|
|
83
|
+
return 0.0;
|
|
84
|
+
}
|
|
85
|
+
v = x - mu;
|
|
86
|
+
return A / ( x * sqrt( x ) ) * exp( B * v * v / x );
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// EXPORTS //
|
|
92
|
+
|
|
93
|
+
module.exports = factory;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Wald distribution probability density function (PDF).
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/stats-base-dists-wald-pdf
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var pdf = require( '@stdlib/stats-base-dists-wald-pdf' );
|
|
28
|
+
*
|
|
29
|
+
* var y = pdf( 2.0, 1.0, 1.0 );
|
|
30
|
+
* // returns ~0.110
|
|
31
|
+
*
|
|
32
|
+
* var myPDF = pdf.factory( 1.0, 1.0 );
|
|
33
|
+
* y = myPDF( 0.5 );
|
|
34
|
+
* // returns ~0.879
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// MODULES //
|
|
38
|
+
|
|
39
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
40
|
+
var main = require( './main.js' );
|
|
41
|
+
var factory = require( './factory.js' );
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// MAIN //
|
|
45
|
+
|
|
46
|
+
setReadOnly( main, 'factory', factory );
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// EXPORTS //
|
|
50
|
+
|
|
51
|
+
module.exports = main;
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var exp = require( '@stdlib/math-base-special-exp' );
|
|
24
|
+
var sqrt = require( '@stdlib/math-base-special-sqrt' );
|
|
25
|
+
var TWO_PI = require( '@stdlib/constants-float64-two-pi' );
|
|
26
|
+
var PINF = require( '@stdlib/constants-float64-pinf' );
|
|
27
|
+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// MAIN //
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Evaluates the probability density function (PDF) for a Wald distribution with mean `mu` and shape parameter `lambda` at a value `x`.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} x - input value
|
|
36
|
+
* @param {PositiveNumber} mu - mean
|
|
37
|
+
* @param {PositiveNumber} lambda - shape parameter
|
|
38
|
+
* @returns {number} evaluated probability density function
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var y = pdf( 2.0, 1.0, 1.0 );
|
|
42
|
+
* // returns ~0.110
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var y = pdf( 0.5, 2.0, 3.0 );
|
|
46
|
+
* // returns ~0.362
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var y = pdf( NaN, 1.0, 1.0 );
|
|
50
|
+
* // returns NaN
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var y = pdf( 1.0, NaN, 1.0 );
|
|
54
|
+
* // returns NaN
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* var y = pdf( 1.0, 1.0, NaN );
|
|
58
|
+
* // returns NaN
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Non-positive mean:
|
|
62
|
+
* var y = pdf( 2.0, 0.0, 1.0 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* var y = pdf( 2.0, -1.0, 1.0 );
|
|
67
|
+
* // returns NaN
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Negative shape parameter:
|
|
71
|
+
* var y = pdf( 2.0, 1.0, -1.0 );
|
|
72
|
+
* // returns NaN
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Zero shape parameter (degenerate distribution):
|
|
76
|
+
* var y = pdf( 2.0, 1.0, 0.0 );
|
|
77
|
+
* // returns 0.0
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* var y = pdf( 1.0, 1.0, 0.0 );
|
|
81
|
+
* // returns Infinity
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Non-positive x:
|
|
85
|
+
* var y = pdf( 0.0, 1.0, 1.0 );
|
|
86
|
+
* // returns 0.0
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* var y = pdf( -1.0, 1.0, 1.0 );
|
|
90
|
+
* // returns 0.0
|
|
91
|
+
*/
|
|
92
|
+
function pdf( x, mu, lambda ) {
|
|
93
|
+
var A;
|
|
94
|
+
var B;
|
|
95
|
+
var v;
|
|
96
|
+
if (
|
|
97
|
+
isnan( x ) ||
|
|
98
|
+
isnan( mu ) ||
|
|
99
|
+
isnan( lambda ) ||
|
|
100
|
+
mu <= 0.0 ||
|
|
101
|
+
lambda < 0.0
|
|
102
|
+
) {
|
|
103
|
+
return NaN;
|
|
104
|
+
}
|
|
105
|
+
if ( lambda === 0.0 ) {
|
|
106
|
+
return ( x === mu ) ? PINF : 0.0;
|
|
107
|
+
}
|
|
108
|
+
if ( x <= 0.0 || !isFinite( x ) ) {
|
|
109
|
+
return 0.0;
|
|
110
|
+
}
|
|
111
|
+
A = sqrt( lambda / TWO_PI );
|
|
112
|
+
B = -lambda / ( 2.0 * mu * mu );
|
|
113
|
+
v = x - mu;
|
|
114
|
+
return A / ( x * sqrt( x ) ) * exp( B * v * v / x );
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// EXPORTS //
|
|
119
|
+
|
|
120
|
+
module.exports = pdf;
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Evaluates the probability density function (PDF) for a Wald distribution with mean `mu` and shape parameter `lambda` at a value `x`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} x - input value
|
|
33
|
+
* @param {PositiveNumber} mu - mean
|
|
34
|
+
* @param {PositiveNumber} lambda - shape parameter
|
|
35
|
+
* @returns {number} evaluated probability density function
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = pdf( 2.0, 1.0, 1.0 );
|
|
39
|
+
* // returns ~0.110
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = pdf( 0.5, 2.0, 3.0 );
|
|
43
|
+
* // returns ~0.362
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = pdf( NaN, 1.0, 1.0 );
|
|
47
|
+
* // returns NaN
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = pdf( 1.0, NaN, 1.0 );
|
|
51
|
+
* // returns NaN
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = pdf( 1.0, 1.0, NaN );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Non-positive mean:
|
|
59
|
+
* var y = pdf( 2.0, 0.0, 1.0 );
|
|
60
|
+
* // returns NaN
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* var y = pdf( 2.0, -1.0, 1.0 );
|
|
64
|
+
* // returns NaN
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Negative shape parameter:
|
|
68
|
+
* var y = pdf( 2.0, 1.0, -1.0 );
|
|
69
|
+
* // returns NaN
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Zero shape parameter (degenerate distribution):
|
|
73
|
+
* var y = pdf( 2.0, 1.0, 0.0 );
|
|
74
|
+
* // returns 0.0
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* var y = pdf( 1.0, 1.0, 0.0 );
|
|
78
|
+
* // returns Infinity
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Non-positive x:
|
|
82
|
+
* var y = pdf( 0.0, 1.0, 1.0 );
|
|
83
|
+
* // returns 0.0
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* var y = pdf( -1.0, 1.0, 1.0 );
|
|
87
|
+
* // returns 0.0
|
|
88
|
+
*/
|
|
89
|
+
function pdf( x, mu, lambda ) {
|
|
90
|
+
return addon( x, mu, lambda );
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
// EXPORTS //
|
|
95
|
+
|
|
96
|
+
module.exports = pdf;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"task": "build",
|
|
4
|
+
"wasm": false
|
|
5
|
+
},
|
|
6
|
+
"fields": [
|
|
7
|
+
{
|
|
8
|
+
"field": "src",
|
|
9
|
+
"resolve": true,
|
|
10
|
+
"relative": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"field": "include",
|
|
14
|
+
"resolve": true,
|
|
15
|
+
"relative": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"field": "libraries",
|
|
19
|
+
"resolve": false,
|
|
20
|
+
"relative": false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"field": "libpath",
|
|
24
|
+
"resolve": true,
|
|
25
|
+
"relative": false
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"confs": [
|
|
29
|
+
{
|
|
30
|
+
"task": "build",
|
|
31
|
+
"wasm": false,
|
|
32
|
+
"src": [
|
|
33
|
+
"./src/main.c"
|
|
34
|
+
],
|
|
35
|
+
"include": [
|
|
36
|
+
"./include"
|
|
37
|
+
],
|
|
38
|
+
"libraries": [],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/math-base-napi-ternary",
|
|
42
|
+
"@stdlib/constants-float64-two-pi",
|
|
43
|
+
"@stdlib/math-base-assert-is-nan",
|
|
44
|
+
"@stdlib/math-base-assert-is-infinite",
|
|
45
|
+
"@stdlib/math-base-special-sqrt",
|
|
46
|
+
"@stdlib/math-base-special-exp",
|
|
47
|
+
"@stdlib/constants-float64-pinf"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"task": "benchmark",
|
|
52
|
+
"wasm": false,
|
|
53
|
+
"src": [
|
|
54
|
+
"./src/main.c"
|
|
55
|
+
],
|
|
56
|
+
"include": [
|
|
57
|
+
"./include"
|
|
58
|
+
],
|
|
59
|
+
"libraries": [],
|
|
60
|
+
"libpath": [],
|
|
61
|
+
"dependencies": [
|
|
62
|
+
"@stdlib/constants-float64-two-pi",
|
|
63
|
+
"@stdlib/math-base-assert-is-nan",
|
|
64
|
+
"@stdlib/math-base-assert-is-infinite",
|
|
65
|
+
"@stdlib/math-base-special-sqrt",
|
|
66
|
+
"@stdlib/math-base-special-exp",
|
|
67
|
+
"@stdlib/constants-float64-pinf",
|
|
68
|
+
"@stdlib/constants-float64-eps"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"task": "examples",
|
|
73
|
+
"wasm": false,
|
|
74
|
+
"src": [
|
|
75
|
+
"./src/main.c"
|
|
76
|
+
],
|
|
77
|
+
"include": [
|
|
78
|
+
"./include"
|
|
79
|
+
],
|
|
80
|
+
"libraries": [],
|
|
81
|
+
"libpath": [],
|
|
82
|
+
"dependencies": [
|
|
83
|
+
"@stdlib/constants-float64-two-pi",
|
|
84
|
+
"@stdlib/math-base-assert-is-nan",
|
|
85
|
+
"@stdlib/math-base-assert-is-infinite",
|
|
86
|
+
"@stdlib/math-base-special-sqrt",
|
|
87
|
+
"@stdlib/math-base-special-exp",
|
|
88
|
+
"@stdlib/constants-float64-pinf",
|
|
89
|
+
"@stdlib/constants-float64-eps"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/stats-base-dists-wald-pdf",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Wald distribution probability density function (PDF).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
18
|
+
"directories": {
|
|
19
|
+
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
21
|
+
"lib": "./lib",
|
|
22
|
+
"src": "./src",
|
|
23
|
+
"dist": "./dist"
|
|
24
|
+
},
|
|
25
|
+
"types": "./docs/types",
|
|
26
|
+
"scripts": {},
|
|
27
|
+
"homepage": "https://stdlib.io",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git://github.com/stdlib-js/stats-base-dists-wald-pdf.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@stdlib/constants-float64-pinf": "^0.2.2",
|
|
37
|
+
"@stdlib/constants-float64-two-pi": "^0.2.2",
|
|
38
|
+
"@stdlib/math-base-assert-is-infinite": "^0.2.2",
|
|
39
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
40
|
+
"@stdlib/math-base-napi-ternary": "^0.3.1",
|
|
41
|
+
"@stdlib/math-base-special-exp": "^0.2.4",
|
|
42
|
+
"@stdlib/math-base-special-sqrt": "^0.2.2",
|
|
43
|
+
"@stdlib/stats-base-dists-degenerate-pdf": "^0.3.0",
|
|
44
|
+
"@stdlib/utils-constant-function": "^0.2.2",
|
|
45
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
46
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=0.10.0",
|
|
51
|
+
"npm": ">2.7.0"
|
|
52
|
+
},
|
|
53
|
+
"os": [
|
|
54
|
+
"aix",
|
|
55
|
+
"darwin",
|
|
56
|
+
"freebsd",
|
|
57
|
+
"linux",
|
|
58
|
+
"macos",
|
|
59
|
+
"openbsd",
|
|
60
|
+
"sunos",
|
|
61
|
+
"win32",
|
|
62
|
+
"windows"
|
|
63
|
+
],
|
|
64
|
+
"keywords": [
|
|
65
|
+
"stdlib",
|
|
66
|
+
"stdmath",
|
|
67
|
+
"statistics",
|
|
68
|
+
"stats",
|
|
69
|
+
"distribution",
|
|
70
|
+
"dist",
|
|
71
|
+
"continuous",
|
|
72
|
+
"probability",
|
|
73
|
+
"pdf",
|
|
74
|
+
"wald",
|
|
75
|
+
"inverse-gaussian",
|
|
76
|
+
"inverse gaussian",
|
|
77
|
+
"univariate"
|
|
78
|
+
],
|
|
79
|
+
"funding": {
|
|
80
|
+
"type": "opencollective",
|
|
81
|
+
"url": "https://opencollective.com/stdlib"
|
|
82
|
+
}
|
|
83
|
+
}
|