@stdlib/stats-base-dists-laplace-pdf 0.2.1 → 0.3.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/NOTICE +1 -1
- package/README.md +112 -18
- package/include/stdlib/stats/base/dists/laplace/pdf.h +38 -0
- package/lib/native.js +73 -0
- package/manifest.json +83 -0
- package/package.json +11 -6
- package/src/addon.c +22 -0
- package/src/main.c +48 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -138,21 +138,111 @@ y = mypdf( 12.0 );
|
|
|
138
138
|
<!-- eslint no-undef: "error" -->
|
|
139
139
|
|
|
140
140
|
```javascript
|
|
141
|
-
var
|
|
141
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
142
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
142
143
|
var pdf = require( '@stdlib/stats-base-dists-laplace-pdf' );
|
|
143
144
|
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
145
|
+
var opts = {
|
|
146
|
+
'dtype': 'float64'
|
|
147
|
+
};
|
|
148
|
+
var x = uniform( 100, 0.0, 10.0, opts );
|
|
149
|
+
var mu = uniform( 100, 0.0, 10.0, opts );
|
|
150
|
+
var b = uniform( 100, 0.0, 10.0, opts );
|
|
151
|
+
|
|
152
|
+
logEachMap( 'x: %0.4f, µ: %0.4f, b: %0.4f, f(x;µ,b): %0.4f', x, mu, b, pdf );
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
</section>
|
|
156
|
+
|
|
157
|
+
<!-- /.examples -->
|
|
158
|
+
|
|
159
|
+
<!-- C interface documentation. -->
|
|
160
|
+
|
|
161
|
+
* * *
|
|
162
|
+
|
|
163
|
+
<section class="c">
|
|
164
|
+
|
|
165
|
+
## C APIs
|
|
166
|
+
|
|
167
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
168
|
+
|
|
169
|
+
<section class="intro">
|
|
170
|
+
|
|
171
|
+
</section>
|
|
172
|
+
|
|
173
|
+
<!-- /.intro -->
|
|
174
|
+
|
|
175
|
+
<!-- C usage documentation. -->
|
|
176
|
+
|
|
177
|
+
<section class="usage">
|
|
178
|
+
|
|
179
|
+
### Usage
|
|
180
|
+
|
|
181
|
+
```c
|
|
182
|
+
#include "stdlib/stats/base/dists/laplace/pdf.h"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### stdlib_base_dists_laplace_pdf( x, mu, b )
|
|
186
|
+
|
|
187
|
+
Evaluates the [probability density function][pdf] (PDF) for a [Laplace][laplace-distribution] distribution with parameters `mu` (location parameter) and `b > 0` (scale parameter).
|
|
188
|
+
|
|
189
|
+
```c
|
|
190
|
+
double out = stdlib_base_dists_laplace_pdf( 2.0, 0.0, 1.0 );
|
|
191
|
+
// returns ~0.068
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The function accepts the following arguments:
|
|
195
|
+
|
|
196
|
+
- **x**: `[in] double` input value.
|
|
197
|
+
- **mu**: `[in] double` location parameter.
|
|
198
|
+
- **b**: `[in] double` scale parameter.
|
|
199
|
+
|
|
200
|
+
```c
|
|
201
|
+
double stdlib_base_dists_laplace_pdf( const double x, const double mu, const double b );
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
</section>
|
|
205
|
+
|
|
206
|
+
<!-- /.usage -->
|
|
207
|
+
|
|
208
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
209
|
+
|
|
210
|
+
<section class="notes">
|
|
211
|
+
|
|
212
|
+
</section>
|
|
213
|
+
|
|
214
|
+
<!-- /.notes -->
|
|
215
|
+
|
|
216
|
+
<!-- C API usage examples. -->
|
|
217
|
+
|
|
218
|
+
<section class="examples">
|
|
219
|
+
|
|
220
|
+
### Examples
|
|
221
|
+
|
|
222
|
+
```c
|
|
223
|
+
#include "stdlib/stats/base/dists/laplace/pdf.h"
|
|
224
|
+
#include <stdlib.h>
|
|
225
|
+
#include <stdio.h>
|
|
226
|
+
|
|
227
|
+
static double random_uniform( const double min, const double max ) {
|
|
228
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
229
|
+
return min + ( v*(max-min) );
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
int main( void ) {
|
|
233
|
+
double mu;
|
|
234
|
+
double x;
|
|
235
|
+
double b;
|
|
236
|
+
double y;
|
|
237
|
+
int i;
|
|
238
|
+
|
|
239
|
+
for ( i = 0; i < 25; i++ ) {
|
|
240
|
+
x = random_uniform( 0.0, 10.0 );
|
|
241
|
+
mu = random_uniform( 0.0, 10.0 );
|
|
242
|
+
b = random_uniform( 0.0, 10.0 );
|
|
243
|
+
y = stdlib_base_dists_laplace_pdf( x, mu, b );
|
|
244
|
+
printf( "x: %lf, µ: %lf, b: %lf, f(x;µ,b): %lf\n", x, mu, b, y );
|
|
245
|
+
}
|
|
156
246
|
}
|
|
157
247
|
```
|
|
158
248
|
|
|
@@ -160,6 +250,10 @@ for ( i = 0; i < 100; i++ ) {
|
|
|
160
250
|
|
|
161
251
|
<!-- /.examples -->
|
|
162
252
|
|
|
253
|
+
</section>
|
|
254
|
+
|
|
255
|
+
<!-- /.c -->
|
|
256
|
+
|
|
163
257
|
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
164
258
|
|
|
165
259
|
<section class="related">
|
|
@@ -194,7 +288,7 @@ See [LICENSE][stdlib-license].
|
|
|
194
288
|
|
|
195
289
|
## Copyright
|
|
196
290
|
|
|
197
|
-
Copyright © 2016-
|
|
291
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
198
292
|
|
|
199
293
|
</section>
|
|
200
294
|
|
|
@@ -207,8 +301,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
207
301
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-laplace-pdf.svg
|
|
208
302
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-laplace-pdf
|
|
209
303
|
|
|
210
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-laplace-pdf/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
211
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-laplace-pdf/actions/workflows/test.yml?query=branch:v0.
|
|
304
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-laplace-pdf/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
305
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-laplace-pdf/actions/workflows/test.yml?query=branch:v0.3.0
|
|
212
306
|
|
|
213
307
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-laplace-pdf/main.svg
|
|
214
308
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-laplace-pdf?branch=main
|
|
@@ -220,8 +314,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
220
314
|
|
|
221
315
|
-->
|
|
222
316
|
|
|
223
|
-
[chat-image]: https://img.shields.io/
|
|
224
|
-
[chat-url]: https://
|
|
317
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
318
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
225
319
|
|
|
226
320
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
227
321
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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_LAPLACE_PDF_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_LAPLACE_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 Laplace distribution with location parameter `mu` and scale parameter `b` at a value `x`.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_laplace_pdf( const double x, const double mu, const double b );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_LAPLACE_PDF_H
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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 Laplace distribution with location parameter `mu` and scale parameter `b` at a value `x`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} x - input value
|
|
33
|
+
* @param {number} mu - location parameter
|
|
34
|
+
* @param {PositiveNumber} b - scale parameter
|
|
35
|
+
* @returns {number} evaluated PDF
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = pdf( 2.0, 0.0, 1.0 );
|
|
39
|
+
* // returns ~0.068
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = pdf( -1.0, 2.0, 3.0 );
|
|
43
|
+
* // returns ~0.061
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = pdf( 2.5, 2.0, 3.0 );
|
|
47
|
+
* // returns ~0.141
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = pdf( NaN, 0.0, 1.0 );
|
|
51
|
+
* // returns NaN
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = pdf( 0.0, NaN, 1.0 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = pdf( 0.0, 0.0, NaN );
|
|
59
|
+
* // returns NaN
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // Negative scale parameter:
|
|
63
|
+
* var y = pdf( 2.0, 0.0, -1.0 );
|
|
64
|
+
* // returns NaN
|
|
65
|
+
*/
|
|
66
|
+
function pdf( x, mu, b ) {
|
|
67
|
+
return addon( x, mu, b );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// EXPORTS //
|
|
72
|
+
|
|
73
|
+
module.exports = pdf;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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/math-base-assert-is-nan",
|
|
43
|
+
"@stdlib/math-base-special-abs",
|
|
44
|
+
"@stdlib/math-base-special-exp"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"task": "benchmark",
|
|
49
|
+
"wasm": false,
|
|
50
|
+
"src": [
|
|
51
|
+
"./src/main.c"
|
|
52
|
+
],
|
|
53
|
+
"include": [
|
|
54
|
+
"./include"
|
|
55
|
+
],
|
|
56
|
+
"libraries": [],
|
|
57
|
+
"libpath": [],
|
|
58
|
+
"dependencies": [
|
|
59
|
+
"@stdlib/math-base-assert-is-nan",
|
|
60
|
+
"@stdlib/math-base-special-abs",
|
|
61
|
+
"@stdlib/math-base-special-exp",
|
|
62
|
+
"@stdlib/constants-float64-eps"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"task": "examples",
|
|
67
|
+
"wasm": false,
|
|
68
|
+
"src": [
|
|
69
|
+
"./src/main.c"
|
|
70
|
+
],
|
|
71
|
+
"include": [
|
|
72
|
+
"./include"
|
|
73
|
+
],
|
|
74
|
+
"libraries": [],
|
|
75
|
+
"libpath": [],
|
|
76
|
+
"dependencies": [
|
|
77
|
+
"@stdlib/math-base-assert-is-nan",
|
|
78
|
+
"@stdlib/math-base-special-abs",
|
|
79
|
+
"@stdlib/math-base-special-exp"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-laplace-pdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Laplace distribution probability density function (PDF).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
17
18
|
"directories": {
|
|
18
19
|
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
19
21
|
"lib": "./lib",
|
|
22
|
+
"src": "./src",
|
|
20
23
|
"dist": "./dist"
|
|
21
24
|
},
|
|
22
25
|
"types": "./docs/types",
|
|
@@ -30,11 +33,13 @@
|
|
|
30
33
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.
|
|
34
|
-
"@stdlib/math-base-
|
|
35
|
-
"@stdlib/math-base-special-
|
|
36
|
-
"@stdlib/
|
|
37
|
-
"@stdlib/utils-
|
|
36
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
37
|
+
"@stdlib/math-base-napi-ternary": "^0.3.1",
|
|
38
|
+
"@stdlib/math-base-special-abs": "^0.2.2",
|
|
39
|
+
"@stdlib/math-base-special-exp": "^0.2.4",
|
|
40
|
+
"@stdlib/utils-constant-function": "^0.2.2",
|
|
41
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
42
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {},
|
|
40
45
|
"engines": {
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
#include "stdlib/stats/base/dists/laplace/pdf.h"
|
|
20
|
+
#include "stdlib/math/base/napi/ternary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_laplace_pdf )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
#include "stdlib/stats/base/dists/laplace/pdf.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/math/base/special/abs.h"
|
|
22
|
+
#include "stdlib/math/base/special/exp.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates the probability density function (PDF) for a Laplace distribution with location parameter `mu` and scale parameter `b` at a value `x`.
|
|
26
|
+
*
|
|
27
|
+
* @param x input value
|
|
28
|
+
* @param mu location parameter
|
|
29
|
+
* @param b scale parameter
|
|
30
|
+
* @return evaluated PDF
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* double y = stdlib_base_dists_laplace_pdf( 2.0, 0.0, 1.0 );
|
|
34
|
+
* // returns ~0.068
|
|
35
|
+
*/
|
|
36
|
+
double stdlib_base_dists_laplace_pdf( const double x, const double mu, const double b ) {
|
|
37
|
+
double z;
|
|
38
|
+
if (
|
|
39
|
+
stdlib_base_is_nan( x ) ||
|
|
40
|
+
stdlib_base_is_nan( mu ) ||
|
|
41
|
+
stdlib_base_is_nan( b ) ||
|
|
42
|
+
b <= 0
|
|
43
|
+
) {
|
|
44
|
+
return 0.0/0.0; // NaN
|
|
45
|
+
}
|
|
46
|
+
z = ( x - mu ) / b;
|
|
47
|
+
return 0.5 / b * stdlib_base_exp( -stdlib_base_abs( z ) );
|
|
48
|
+
}
|