@stdlib/stats-base-dists-kumaraswamy-logcdf 0.2.0 → 0.2.2
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 +111 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/docs/types/index.d.ts +3 -3
- package/include/stdlib/stats/base/dists/kumaraswamy/logcdf.h +38 -0
- package/lib/index.js +1 -1
- package/lib/native.js +88 -0
- package/manifest.json +85 -0
- package/package.json +15 -27
- package/src/addon.c +22 -0
- package/src/main.c +54 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -170,22 +170,111 @@ y = mylogcdf( 0.3 );
|
|
|
170
170
|
<!-- eslint no-undef: "error" -->
|
|
171
171
|
|
|
172
172
|
```javascript
|
|
173
|
-
var randu = require( '@stdlib/random-base-randu' );
|
|
174
173
|
var EPS = require( '@stdlib/constants-float64-eps' );
|
|
174
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
175
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
175
176
|
var logcdf = require( '@stdlib/stats-base-dists-kumaraswamy-logcdf' );
|
|
176
177
|
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
var
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
var opts = {
|
|
179
|
+
'dtype': 'float64'
|
|
180
|
+
};
|
|
181
|
+
var x = uniform( 10, 0.0, 1.0, opts );
|
|
182
|
+
var a = uniform( 10, EPS, 5.0, opts );
|
|
183
|
+
var b = uniform( 10, EPS, 5.0, opts );
|
|
184
|
+
|
|
185
|
+
logEachMap( 'x: %0.4f, a: %0.4f, b: %0.4f, ln(F(x;a,b)): %0.4f', x, a, b, logcdf );
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
</section>
|
|
189
|
+
|
|
190
|
+
<!-- /.examples -->
|
|
191
|
+
|
|
192
|
+
<!-- C interface documentation. -->
|
|
193
|
+
|
|
194
|
+
* * *
|
|
195
|
+
|
|
196
|
+
<section class="c">
|
|
197
|
+
|
|
198
|
+
## C APIs
|
|
199
|
+
|
|
200
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
201
|
+
|
|
202
|
+
<section class="intro">
|
|
203
|
+
|
|
204
|
+
</section>
|
|
205
|
+
|
|
206
|
+
<!-- /.intro -->
|
|
207
|
+
|
|
208
|
+
<!-- C usage documentation. -->
|
|
209
|
+
|
|
210
|
+
<section class="usage">
|
|
211
|
+
|
|
212
|
+
### Usage
|
|
213
|
+
|
|
214
|
+
```c
|
|
215
|
+
#include "stdlib/stats/base/dists/kumaraswamy/logcdf.h"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### stdlib_base_dists_kumaraswamy_logcdf( x, a, b )
|
|
219
|
+
|
|
220
|
+
Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution.
|
|
221
|
+
|
|
222
|
+
```c
|
|
223
|
+
double out = stdlib_base_dists_kumaraswamy_logcdf( 0.5, 1.0, 1.0 );
|
|
224
|
+
// returns ~-0.693
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The function accepts the following arguments:
|
|
228
|
+
|
|
229
|
+
- **x**: `[in] double` input value.
|
|
230
|
+
- **a**: `[in] double` first shape parameter.
|
|
231
|
+
- **b**: `[in] double` second shape parameter.
|
|
232
|
+
|
|
233
|
+
```c
|
|
234
|
+
double stdlib_base_dists_kumaraswamy_logcdf( const double x, const double a, const double b );
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
</section>
|
|
238
|
+
|
|
239
|
+
<!-- /.usage -->
|
|
240
|
+
|
|
241
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
242
|
+
|
|
243
|
+
<section class="notes">
|
|
244
|
+
|
|
245
|
+
</section>
|
|
246
|
+
|
|
247
|
+
<!-- /.notes -->
|
|
248
|
+
|
|
249
|
+
<!-- C API usage examples. -->
|
|
250
|
+
|
|
251
|
+
<section class="examples">
|
|
252
|
+
|
|
253
|
+
### Examples
|
|
254
|
+
|
|
255
|
+
```c
|
|
256
|
+
#include "stdlib/stats/base/dists/kumaraswamy/logcdf.h"
|
|
257
|
+
#include <stdlib.h>
|
|
258
|
+
#include <stdio.h>
|
|
259
|
+
|
|
260
|
+
static double random_uniform( const double min, const double max ) {
|
|
261
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
262
|
+
return min + ( v*(max-min) );
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
int main( void ) {
|
|
266
|
+
double x;
|
|
267
|
+
double a;
|
|
268
|
+
double b;
|
|
269
|
+
double y;
|
|
270
|
+
int i;
|
|
271
|
+
for ( i = 0; i < 25; i++ ) {
|
|
272
|
+
x = random_uniform( 0, 1.0 );
|
|
273
|
+
a = random_uniform( 0, 5.0 );
|
|
274
|
+
b = random_uniform( 0, 5.0 );
|
|
275
|
+
y = stdlib_base_dists_kumaraswamy_logcdf( x, a, b );
|
|
276
|
+
printf( "x: %lf, a: %lf, b: %lf, ln(F(x;a,b)): %lf\n", x, a, b, y );
|
|
277
|
+
}
|
|
189
278
|
}
|
|
190
279
|
```
|
|
191
280
|
|
|
@@ -193,6 +282,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
193
282
|
|
|
194
283
|
<!-- /.examples -->
|
|
195
284
|
|
|
285
|
+
</section>
|
|
286
|
+
|
|
287
|
+
<!-- /.c -->
|
|
288
|
+
|
|
196
289
|
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
197
290
|
|
|
198
291
|
<section class="related">
|
|
@@ -227,7 +320,7 @@ See [LICENSE][stdlib-license].
|
|
|
227
320
|
|
|
228
321
|
## Copyright
|
|
229
322
|
|
|
230
|
-
Copyright © 2016-
|
|
323
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
231
324
|
|
|
232
325
|
</section>
|
|
233
326
|
|
|
@@ -240,8 +333,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
240
333
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-kumaraswamy-logcdf.svg
|
|
241
334
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-kumaraswamy-logcdf
|
|
242
335
|
|
|
243
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-kumaraswamy-logcdf/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
244
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-kumaraswamy-logcdf/actions/workflows/test.yml?query=branch:v0.2.
|
|
336
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-kumaraswamy-logcdf/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
337
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-kumaraswamy-logcdf/actions/workflows/test.yml?query=branch:v0.2.2
|
|
245
338
|
|
|
246
339
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-kumaraswamy-logcdf/main.svg
|
|
247
340
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-kumaraswamy-logcdf?branch=main
|
|
@@ -253,8 +346,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
253
346
|
|
|
254
347
|
-->
|
|
255
348
|
|
|
256
|
-
[chat-image]: https://img.shields.io/
|
|
257
|
-
[chat-url]: https://
|
|
349
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
350
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
258
351
|
|
|
259
352
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
260
353
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="../docs/types/index.d.ts" />
|
|
2
|
-
import
|
|
3
|
-
export =
|
|
2
|
+
import logcdf from '../docs/types/index';
|
|
3
|
+
export = logcdf;
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.js", "../lib/factory.js", "../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with first shape parameter `a` and second shape parameter `b` at a value `x`.\n*\n* @param {number} x - input value\n* @param {PositiveNumber} a - first shape parameter\n* @param {PositiveNumber} b - second shape parameter\n* @returns {number} evaluated logCDF\n*\n* @example\n* var y = logcdf( 0.5, 1.0, 1.0 );\n* // returns ~-0.693\n*\n* @example\n* var y = logcdf( 0.5, 2.0, 4.0 );\n* // returns ~-0.38\n*\n* @example\n* var y = logcdf( 0.2, 2.0, 2.0 );\n* // returns ~-2.546\n*\n* @example\n* var y = logcdf( 0.8, 4.0, 4.0 );\n* // returns ~-0.13\n*\n* @example\n* var y = logcdf( -0.5, 4.0, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logcdf( 1.5, 4.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = logcdf( 2.0, -1.0, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 2.0, 0.5, -1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( NaN, 1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 0.0, 1.0, NaN );\n* // returns NaN\n*/\nfunction logcdf( x, a, b ) {\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( a ) ||\n\t\tisnan( b ) ||\n\t\ta <= 0.0 ||\n\t\tb <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( x <= 0.0 ) {\n\t\treturn NINF;\n\t}\n\tif ( x >= 1.0 ) {\n\t\treturn 0.0;\n\t}\n\treturn ln( 1.0 - pow( 1.0 - pow( x, a ), b ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logcdf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with first shape parameter `a` and second shape parameter `b`.\n*\n* @param {PositiveNumber} a - first shape parameter\n* @param {PositiveNumber} b - second shape parameter\n* @returns {Function} CDF\n*\n* @example\n* var logcdf = factory( 0.5, 0.5 );\n*\n* var y = logcdf( 0.8 );\n* // returns ~-0.393\n*\n* y = logcdf( 0.3 );\n* // returns ~-1.116\n*/\nfunction factory( a, b ) {\n\tif (\n\t\tisnan( a ) ||\n\t\tisnan( b ) ||\n\t\ta <= 0.0 ||\n\t\tb <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn logcdf;\n\n\t/**\n\t* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {number} evaluated logCDF\n\t*\n\t* @example\n\t* var y = logcdf( 2.0 );\n\t* // returns <number>\n\t*/\n\tfunction logcdf( x ) {\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x <= 0.0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\tif ( x >= 1.0 ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn ln( 1.0 - pow( 1.0 - pow( x, a ), b ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Evaluate the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution.\n*\n* @module @stdlib/stats-base-dists-kumaraswamy-logcdf\n*\n* @example\n* var logcdf = require( '@stdlib/stats-base-dists-kumaraswamy-logcdf' );\n*\n* var y = logcdf( 0.5, 1.0, 1.0 );\n* // returns ~-0.693\n*\n* y = logcdf( 0.5, 2.0, 4.0 );\n* // returns ~-0.38\n*\n* @example\n* var factory = require( '@stdlib/stats-base-dists-kumaraswamy-logcdf' ).factory;\n*\n* var logcdf = factory( 0.5, 0.5 );\n*\n* var y = logcdf( 0.8 );\n* // returns ~-0.393\n*\n* y = logcdf( 0.3 );\n* // returns ~-1.
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with first shape parameter `a` and second shape parameter `b` at a value `x`.\n*\n* @param {number} x - input value\n* @param {PositiveNumber} a - first shape parameter\n* @param {PositiveNumber} b - second shape parameter\n* @returns {number} evaluated logCDF\n*\n* @example\n* var y = logcdf( 0.5, 1.0, 1.0 );\n* // returns ~-0.693\n*\n* @example\n* var y = logcdf( 0.5, 2.0, 4.0 );\n* // returns ~-0.38\n*\n* @example\n* var y = logcdf( 0.2, 2.0, 2.0 );\n* // returns ~-2.546\n*\n* @example\n* var y = logcdf( 0.8, 4.0, 4.0 );\n* // returns ~-0.13\n*\n* @example\n* var y = logcdf( -0.5, 4.0, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logcdf( 1.5, 4.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = logcdf( 2.0, -1.0, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 2.0, 0.5, -1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( NaN, 1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 0.0, 1.0, NaN );\n* // returns NaN\n*/\nfunction logcdf( x, a, b ) {\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( a ) ||\n\t\tisnan( b ) ||\n\t\ta <= 0.0 ||\n\t\tb <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( x <= 0.0 ) {\n\t\treturn NINF;\n\t}\n\tif ( x >= 1.0 ) {\n\t\treturn 0.0;\n\t}\n\treturn ln( 1.0 - pow( 1.0 - pow( x, a ), b ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logcdf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with first shape parameter `a` and second shape parameter `b`.\n*\n* @param {PositiveNumber} a - first shape parameter\n* @param {PositiveNumber} b - second shape parameter\n* @returns {Function} CDF\n*\n* @example\n* var logcdf = factory( 0.5, 0.5 );\n*\n* var y = logcdf( 0.8 );\n* // returns ~-0.393\n*\n* y = logcdf( 0.3 );\n* // returns ~-1.116\n*/\nfunction factory( a, b ) {\n\tif (\n\t\tisnan( a ) ||\n\t\tisnan( b ) ||\n\t\ta <= 0.0 ||\n\t\tb <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn logcdf;\n\n\t/**\n\t* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {number} evaluated logCDF\n\t*\n\t* @example\n\t* var y = logcdf( 2.0 );\n\t* // returns <number>\n\t*/\n\tfunction logcdf( x ) {\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x <= 0.0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\tif ( x >= 1.0 ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn ln( 1.0 - pow( 1.0 - pow( x, a ), b ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Evaluate the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution.\n*\n* @module @stdlib/stats-base-dists-kumaraswamy-logcdf\n*\n* @example\n* var logcdf = require( '@stdlib/stats-base-dists-kumaraswamy-logcdf' );\n*\n* var y = logcdf( 0.5, 1.0, 1.0 );\n* // returns ~-0.693\n*\n* y = logcdf( 0.5, 2.0, 4.0 );\n* // returns ~-0.38\n*\n* @example\n* var factory = require( '@stdlib/stats-base-dists-kumaraswamy-logcdf' ).factory;\n*\n* var logcdf = factory( 0.5, 0.5 );\n*\n* var y = logcdf( 0.8 );\n* // returns ~-0.393\n*\n* y = logcdf( 0.3 );\n* // returns ~-1.116\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
5
|
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EAC/CC,EAAK,QAAS,8BAA+B,EAC7CC,EAAO,QAAS,gCAAiC,EAyDrD,SAASC,EAAQC,EAAGC,EAAGC,EAAI,CAC1B,OACCP,EAAOK,CAAE,GACTL,EAAOM,CAAE,GACTN,EAAOO,CAAE,GACTD,GAAK,GACLC,GAAK,EAEE,IAEHF,GAAK,EACFF,EAEHE,GAAK,EACF,EAEDH,EAAI,EAAMD,EAAK,EAAMA,EAAKI,EAAGC,CAAE,EAAGC,CAAE,CAAE,CAC9C,CAKAR,EAAO,QAAUK,ICxGjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EAC/CC,EAAK,QAAS,8BAA+B,EAC7CC,EAAO,QAAS,gCAAiC,EAqBrD,SAASC,EAASC,EAAGC,EAAI,CACxB,GACCN,EAAOK,CAAE,GACTL,EAAOM,CAAE,GACTD,GAAK,GACLC,GAAK,EAEL,OAAOP,EAAkB,GAAI,EAE9B,OAAOQ,EAaP,SAASA,EAAQC,EAAI,CACpB,OAAKR,EAAOQ,CAAE,EACN,IAEHA,GAAK,EACFL,EAEHK,GAAK,EACF,EAEDN,EAAI,EAAMD,EAAK,EAAMA,EAAKO,EAAGH,CAAE,EAAGC,CAAE,CAAE,CAC9C,CACD,CAKAR,EAAO,QAAUM,ICtCjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "pow", "ln", "NINF", "logcdf", "x", "a", "b", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "isnan", "pow", "ln", "NINF", "factory", "a", "b", "logcdf", "x", "setReadOnly", "main", "factory"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -128,11 +128,11 @@ interface LogCDF {
|
|
|
128
128
|
* // returns ~-0.393
|
|
129
129
|
*
|
|
130
130
|
* y = mylogcdf( 0.3 );
|
|
131
|
-
* // returns ~-1.
|
|
131
|
+
* // returns ~-1.116
|
|
132
132
|
*/
|
|
133
|
-
declare var
|
|
133
|
+
declare var logcdf: LogCDF;
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
// EXPORTS //
|
|
137
137
|
|
|
138
|
-
export =
|
|
138
|
+
export = logcdf;
|
|
@@ -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_KUMARASWAMY_LOGCDF_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_KUMARASWAMY_LOGCDF_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 natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with parameters `a` (first shape parameter) and `b` (second shape parameter).
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_kumaraswamy_logcdf( const double x, const double a, const double b );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_KUMARASWAMY_LOGCDF_H
|
package/lib/index.js
CHANGED
package/lib/native.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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 natural logarithm of the cumulative density function (CDF) for a uniform distribution with minimum support `a` and maximum support `b` at a value `x`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} x - input value
|
|
33
|
+
* @param {PositiveNumber} a - first shape parameter
|
|
34
|
+
* @param {PositiveNumber} b - second shape parameter
|
|
35
|
+
* @returns {number} evaluated logCDF
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = logcdf( 0.5, 1.0, 1.0 );
|
|
39
|
+
* // returns ~-0.693
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = logcdf( 0.5, 2.0, 4.0 );
|
|
43
|
+
* // returns ~-0.38
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = logcdf( 0.2, 2.0, 2.0 );
|
|
47
|
+
* // returns ~-2.546
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = logcdf( 0.8, 4.0, 4.0 );
|
|
51
|
+
* // returns ~-0.13
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = logcdf( -0.5, 4.0, 2.0 );
|
|
55
|
+
* // returns -Infinity
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = logcdf( 1.5, 4.0, 2.0 );
|
|
59
|
+
* // returns 0.0
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = logcdf( 2.0, -1.0, 0.5 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* var y = logcdf( 2.0, 0.5, -1.0 );
|
|
67
|
+
* // returns NaN
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* var y = logcdf( NaN, 1.0, 1.0 );
|
|
71
|
+
* // returns NaN
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* var y = logcdf( 0.0, NaN, 1.0 );
|
|
75
|
+
* // returns NaN
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* var y = logcdf( 0.0, 1.0, NaN );
|
|
79
|
+
* // returns NaN
|
|
80
|
+
*/
|
|
81
|
+
function logcdf( x, a, b ) {
|
|
82
|
+
return addon( x, a, b );
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// EXPORTS //
|
|
87
|
+
|
|
88
|
+
module.exports = logcdf;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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-pow",
|
|
44
|
+
"@stdlib/math-base-special-ln",
|
|
45
|
+
"@stdlib/constants-float64-ninf"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"task": "benchmark",
|
|
50
|
+
"wasm": false,
|
|
51
|
+
"src": [
|
|
52
|
+
"./src/main.c"
|
|
53
|
+
],
|
|
54
|
+
"include": [
|
|
55
|
+
"./include"
|
|
56
|
+
],
|
|
57
|
+
"libraries": [],
|
|
58
|
+
"libpath": [],
|
|
59
|
+
"dependencies": [
|
|
60
|
+
"@stdlib/math-base-assert-is-nan",
|
|
61
|
+
"@stdlib/math-base-special-pow",
|
|
62
|
+
"@stdlib/math-base-special-ln",
|
|
63
|
+
"@stdlib/constants-float64-ninf"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"task": "examples",
|
|
68
|
+
"wasm": false,
|
|
69
|
+
"src": [
|
|
70
|
+
"./src/main.c"
|
|
71
|
+
],
|
|
72
|
+
"include": [
|
|
73
|
+
"./include"
|
|
74
|
+
],
|
|
75
|
+
"libraries": [],
|
|
76
|
+
"libpath": [],
|
|
77
|
+
"dependencies": [
|
|
78
|
+
"@stdlib/math-base-assert-is-nan",
|
|
79
|
+
"@stdlib/math-base-special-pow",
|
|
80
|
+
"@stdlib/math-base-special-ln",
|
|
81
|
+
"@stdlib/constants-float64-ninf"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-kumaraswamy-logcdf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Natural logarithm of the cumulative distribution function (CDF)for a Kumaraswamy's double bounded distribution.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -14,20 +14,16 @@
|
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
17
18
|
"directories": {
|
|
18
|
-
"benchmark": "./benchmark",
|
|
19
19
|
"doc": "./docs",
|
|
20
|
-
"
|
|
20
|
+
"include": "./include",
|
|
21
21
|
"lib": "./lib",
|
|
22
|
-
"
|
|
22
|
+
"src": "./src",
|
|
23
|
+
"dist": "./dist"
|
|
23
24
|
},
|
|
24
25
|
"types": "./docs/types",
|
|
25
|
-
"scripts": {
|
|
26
|
-
"test": "make test",
|
|
27
|
-
"test-cov": "make test-cov",
|
|
28
|
-
"examples": "make examples",
|
|
29
|
-
"benchmark": "make benchmark"
|
|
30
|
-
},
|
|
26
|
+
"scripts": {},
|
|
31
27
|
"homepage": "https://stdlib.io",
|
|
32
28
|
"repository": {
|
|
33
29
|
"type": "git",
|
|
@@ -37,24 +33,16 @@
|
|
|
37
33
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
34
|
},
|
|
39
35
|
"dependencies": {
|
|
40
|
-
"@stdlib/constants-float64-ninf": "^0.2.
|
|
41
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.
|
|
42
|
-
"@stdlib/math-base-
|
|
43
|
-
"@stdlib/math-base-special-
|
|
44
|
-
"@stdlib/
|
|
45
|
-
"@stdlib/utils-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"@stdlib/assert-is-number": "^0.1.1",
|
|
49
|
-
"@stdlib/constants-float64-eps": "^0.1.1",
|
|
50
|
-
"@stdlib/constants-float64-pinf": "^0.1.1",
|
|
51
|
-
"@stdlib/random-base-randu": "^0.1.0",
|
|
52
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
53
|
-
"istanbul": "^0.4.1",
|
|
54
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
55
|
-
"@stdlib/bench-harness": "^0.2.0",
|
|
56
|
-
"@stdlib/bench": "^0.3.1"
|
|
36
|
+
"@stdlib/constants-float64-ninf": "^0.2.3",
|
|
37
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.3",
|
|
38
|
+
"@stdlib/math-base-napi-ternary": "^0.3.2",
|
|
39
|
+
"@stdlib/math-base-special-ln": "^0.2.5",
|
|
40
|
+
"@stdlib/math-base-special-pow": "^0.3.0",
|
|
41
|
+
"@stdlib/utils-constant-function": "^0.2.3",
|
|
42
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
|
|
43
|
+
"@stdlib/utils-library-manifest": "^0.2.4"
|
|
57
44
|
},
|
|
45
|
+
"devDependencies": {},
|
|
58
46
|
"engines": {
|
|
59
47
|
"node": ">=0.10.0",
|
|
60
48
|
"npm": ">2.7.0"
|
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/kumaraswamy/logcdf.h"
|
|
20
|
+
#include "stdlib/math/base/napi/ternary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_kumaraswamy_logcdf )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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/kumaraswamy/logcdf.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/math/base/special/pow.h"
|
|
22
|
+
#include "stdlib/math/base/special/ln.h"
|
|
23
|
+
#include "stdlib/constants/float64/ninf.h"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Kumaraswamy's double bounded distribution with first shape parameter `a` and second shape parameter `b` at a value `x`.
|
|
27
|
+
*
|
|
28
|
+
* @param x input value
|
|
29
|
+
* @param a first shape parameter
|
|
30
|
+
* @param b second shape parameter
|
|
31
|
+
* @return evaluated logCDF
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* double y = stdlib_base_dists_kumaraswamy_logcdf( 0.5, 1.0, 1.0 );
|
|
35
|
+
* // returns ~-0.693
|
|
36
|
+
*/
|
|
37
|
+
double stdlib_base_dists_kumaraswamy_logcdf( const double x, const double a, const double b ) {
|
|
38
|
+
if (
|
|
39
|
+
stdlib_base_is_nan( x ) ||
|
|
40
|
+
stdlib_base_is_nan( a ) ||
|
|
41
|
+
stdlib_base_is_nan( b ) ||
|
|
42
|
+
a <= 0.0 ||
|
|
43
|
+
b <= 0.0
|
|
44
|
+
) {
|
|
45
|
+
return 0.0/0.0; // NaN
|
|
46
|
+
}
|
|
47
|
+
if ( x <= 0.0 ) {
|
|
48
|
+
return STDLIB_CONSTANT_FLOAT64_NINF;
|
|
49
|
+
}
|
|
50
|
+
if ( x >= 1.0 ) {
|
|
51
|
+
return 0.0;
|
|
52
|
+
}
|
|
53
|
+
return stdlib_base_ln( 1.0 - stdlib_base_pow( 1.0 - stdlib_base_pow( x, a ), b ) );
|
|
54
|
+
}
|