@stdlib/stats-base-dists-exponential-quantile 0.2.2 → 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 +116 -16
- package/include/stdlib/stats/base/dists/exponential/quantile.h +38 -0
- package/lib/native.js +72 -0
- package/manifest.json +83 -0
- package/package.json +8 -3
- package/src/addon.c +22 -0
- package/src/main.c +46 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ var quantile = require( '@stdlib/stats-base-dists-exponential-quantile' );
|
|
|
74
74
|
|
|
75
75
|
#### quantile( p, lambda )
|
|
76
76
|
|
|
77
|
-
Evaluates the [quantile function][quantile-function] for
|
|
77
|
+
Evaluates the [quantile function][quantile-function] for an [exponential][exponential-distribution] distribution with rate parameter `lambda`.
|
|
78
78
|
|
|
79
79
|
```javascript
|
|
80
80
|
var y = quantile( 0.5, 0.1 );
|
|
@@ -136,19 +136,107 @@ y = myquantile( 0.9 );
|
|
|
136
136
|
<!-- eslint no-undef: "error" -->
|
|
137
137
|
|
|
138
138
|
```javascript
|
|
139
|
-
var
|
|
139
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
140
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
140
141
|
var quantile = require( '@stdlib/stats-base-dists-exponential-quantile' );
|
|
141
142
|
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var
|
|
143
|
+
var opts = {
|
|
144
|
+
'dtype': 'float64'
|
|
145
|
+
};
|
|
146
|
+
var p = uniform( 10, 0.0, 1.0, opts );
|
|
147
|
+
var lambda = uniform( 10, 0.0, 10.0, opts );
|
|
146
148
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
logEachMap( 'p: %0.4f, λ: %0.4f, Q(p;λ): %0.4f', p, lambda, quantile );
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
</section>
|
|
153
|
+
|
|
154
|
+
<!-- /.examples -->
|
|
155
|
+
|
|
156
|
+
<!-- C interface documentation. -->
|
|
157
|
+
|
|
158
|
+
* * *
|
|
159
|
+
|
|
160
|
+
<section class="c">
|
|
161
|
+
|
|
162
|
+
## C APIs
|
|
163
|
+
|
|
164
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
165
|
+
|
|
166
|
+
<section class="intro">
|
|
167
|
+
|
|
168
|
+
</section>
|
|
169
|
+
|
|
170
|
+
<!-- /.intro -->
|
|
171
|
+
|
|
172
|
+
<!-- C usage documentation. -->
|
|
173
|
+
|
|
174
|
+
<section class="usage">
|
|
175
|
+
|
|
176
|
+
### Usage
|
|
177
|
+
|
|
178
|
+
```c
|
|
179
|
+
#include "stdlib/stats/base/dists/exponential/quantile.h"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### stdlib_base_dists_exponential_quantile( p, lambda )
|
|
183
|
+
|
|
184
|
+
Evaluates the [quantile function][quantile-function] for an [exponential][exponential-distribution] distribution with rate parameter `lambda`.
|
|
185
|
+
|
|
186
|
+
```c
|
|
187
|
+
double out = stdlib_base_dists_exponential_quantile( 0.8, 1.0 );
|
|
188
|
+
// returns ~1.609
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The function accepts the following arguments:
|
|
192
|
+
|
|
193
|
+
- **p**: `[in] double` probability.
|
|
194
|
+
- **lambda**: `[in] double` rate parameter.
|
|
195
|
+
|
|
196
|
+
```c
|
|
197
|
+
double stdlib_base_dists_exponential_quantile( const double p, const double lambda );
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
</section>
|
|
201
|
+
|
|
202
|
+
<!-- /.usage -->
|
|
203
|
+
|
|
204
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
205
|
+
|
|
206
|
+
<section class="notes">
|
|
207
|
+
|
|
208
|
+
</section>
|
|
209
|
+
|
|
210
|
+
<!-- /.notes -->
|
|
211
|
+
|
|
212
|
+
<!-- C API usage examples. -->
|
|
213
|
+
|
|
214
|
+
<section class="examples">
|
|
215
|
+
|
|
216
|
+
### Examples
|
|
217
|
+
|
|
218
|
+
```c
|
|
219
|
+
#include "stdlib/stats/base/dists/exponential/quantile.h"
|
|
220
|
+
#include <stdlib.h>
|
|
221
|
+
#include <stdio.h>
|
|
222
|
+
|
|
223
|
+
static double random_uniform( const double min, const double max ) {
|
|
224
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
225
|
+
return min + ( v*(max-min) );
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
int main( void ) {
|
|
229
|
+
double lambda;
|
|
230
|
+
double y;
|
|
231
|
+
double p;
|
|
232
|
+
int i;
|
|
233
|
+
|
|
234
|
+
for ( i = 0; i < 25; i++ ) {
|
|
235
|
+
p = random_uniform( 0.0, 1.0 );
|
|
236
|
+
lambda = random_uniform( 0.0, 20.0 );
|
|
237
|
+
y = stdlib_base_dists_exponential_quantile( p, lambda );
|
|
238
|
+
printf( "p: %lf, λ: %lf, Q(p;λ): %lf\n", p, lambda, y );
|
|
239
|
+
}
|
|
152
240
|
}
|
|
153
241
|
```
|
|
154
242
|
|
|
@@ -156,6 +244,18 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
156
244
|
|
|
157
245
|
<!-- /.examples -->
|
|
158
246
|
|
|
247
|
+
</section>
|
|
248
|
+
|
|
249
|
+
<!-- /.c -->
|
|
250
|
+
|
|
251
|
+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
252
|
+
|
|
253
|
+
<section class="references">
|
|
254
|
+
|
|
255
|
+
</section>
|
|
256
|
+
|
|
257
|
+
<!-- /.references -->
|
|
258
|
+
|
|
159
259
|
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
160
260
|
|
|
161
261
|
<section class="related">
|
|
@@ -190,7 +290,7 @@ See [LICENSE][stdlib-license].
|
|
|
190
290
|
|
|
191
291
|
## Copyright
|
|
192
292
|
|
|
193
|
-
Copyright © 2016-
|
|
293
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
194
294
|
|
|
195
295
|
</section>
|
|
196
296
|
|
|
@@ -203,8 +303,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
203
303
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-exponential-quantile.svg
|
|
204
304
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-exponential-quantile
|
|
205
305
|
|
|
206
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-exponential-quantile/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
207
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-exponential-quantile/actions/workflows/test.yml?query=branch:v0.
|
|
306
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-exponential-quantile/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
307
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-exponential-quantile/actions/workflows/test.yml?query=branch:v0.3.0
|
|
208
308
|
|
|
209
309
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-exponential-quantile/main.svg
|
|
210
310
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-exponential-quantile?branch=main
|
|
@@ -216,8 +316,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
216
316
|
|
|
217
317
|
-->
|
|
218
318
|
|
|
219
|
-
[chat-image]: https://img.shields.io/
|
|
220
|
-
[chat-url]: https://
|
|
319
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
320
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
221
321
|
|
|
222
322
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
223
323
|
|
|
@@ -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_EXPONENTIAL_QUANTILE_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_EXPONENTIAL_QUANTILE_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 quantile function for an exponential distribution with rate parameter `lambda` at a probability `p`.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_exponential_quantile( const double p, const double lambda );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_EXPONENTIAL_QUANTILE_H
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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 quantile function for an exponential distribution with rate parameter `lambda` at a probability `p`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {Probability} p - input value
|
|
33
|
+
* @param {PositiveNumber} lambda - rate parameter
|
|
34
|
+
* @returns {number} evaluated quantile function
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var y = quantile( 0.8, 1.0 );
|
|
38
|
+
* // returns ~1.609
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var y = quantile( 0.5, 4.0 );
|
|
42
|
+
* // returns ~0.173
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var y = quantile( 0.5, 0.1 );
|
|
46
|
+
* // returns ~6.931
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var y = quantile( -0.2, 0.1 );
|
|
50
|
+
* // returns NaN
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var y = quantile( NaN, 1.0 );
|
|
54
|
+
* // returns NaN
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* var y = quantile( 0.0, NaN );
|
|
58
|
+
* // returns NaN
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Negative rate parameter:
|
|
62
|
+
* var y = quantile( 0.5, -1.0 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*/
|
|
65
|
+
function quantile( p, lambda ) {
|
|
66
|
+
return addon( p, lambda );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// EXPORTS //
|
|
71
|
+
|
|
72
|
+
module.exports = quantile;
|
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-binary",
|
|
42
|
+
"@stdlib/math-base-assert-is-nan",
|
|
43
|
+
"@stdlib/constants-float64-pinf",
|
|
44
|
+
"@stdlib/math-base-special-ln"
|
|
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/constants-float64-eps",
|
|
61
|
+
"@stdlib/constants-float64-pinf",
|
|
62
|
+
"@stdlib/math-base-special-ln"
|
|
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/constants-float64-pinf",
|
|
79
|
+
"@stdlib/math-base-special-ln"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-exponential-quantile",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Exponential distribution quantile function.",
|
|
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",
|
|
@@ -32,9 +35,11 @@
|
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"@stdlib/constants-float64-pinf": "^0.2.2",
|
|
34
37
|
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
35
|
-
"@stdlib/math-base-
|
|
38
|
+
"@stdlib/math-base-napi-binary": "^0.3.1",
|
|
39
|
+
"@stdlib/math-base-special-ln": "^0.2.4",
|
|
36
40
|
"@stdlib/utils-constant-function": "^0.2.2",
|
|
37
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^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/exponential/quantile.h"
|
|
20
|
+
#include "stdlib/math/base/napi/binary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_exponential_quantile )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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/exponential/quantile.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/constants/float64/pinf.h"
|
|
22
|
+
#include "stdlib/math/base/special/ln.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates the quantile function for an exponential distribution with rate parameter `lambda` at a probability `p`.
|
|
26
|
+
* @param p - input probability
|
|
27
|
+
* @param lambda rate parameter
|
|
28
|
+
* @return quantile
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* double y = stdlib_base_exponential_quantile( 0.8, 1.0 );
|
|
32
|
+
* // returns ~1.609
|
|
33
|
+
*/
|
|
34
|
+
double stdlib_base_dists_exponential_quantile( const double p, const double lambda ) {
|
|
35
|
+
if (
|
|
36
|
+
stdlib_base_is_nan( lambda ) ||
|
|
37
|
+
lambda < 0.0 ||
|
|
38
|
+
lambda == STDLIB_CONSTANT_FLOAT64_PINF ||
|
|
39
|
+
stdlib_base_is_nan( p ) ||
|
|
40
|
+
p < 0.0 ||
|
|
41
|
+
p > 1.0
|
|
42
|
+
) {
|
|
43
|
+
return 0.0 / 0.0; // NaN
|
|
44
|
+
}
|
|
45
|
+
return -stdlib_base_ln( 1.0 - p ) / lambda;
|
|
46
|
+
}
|