@stdlib/stats-base-dists-binomial-kurtosis 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 +110 -16
- package/dist/index.js.map +1 -1
- package/docs/types/index.d.ts +1 -1
- package/include/stdlib/stats/base/dists/binomial/kurtosis.h +40 -0
- package/lib/main.js +1 -1
- package/lib/native.js +59 -0
- package/manifest.json +78 -0
- package/package.json +7 -2
- package/src/addon.c +22 -0
- package/src/main.c +45 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -139,20 +139,110 @@ v = kurtosis( 20, 1.5 );
|
|
|
139
139
|
<!-- eslint no-undef: "error" -->
|
|
140
140
|
|
|
141
141
|
```javascript
|
|
142
|
-
var
|
|
143
|
-
var
|
|
142
|
+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
|
|
143
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
144
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
144
145
|
var kurtosis = require( '@stdlib/stats-base-dists-binomial-kurtosis' );
|
|
145
146
|
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var
|
|
147
|
+
var opts = {
|
|
148
|
+
'dtype': 'float64'
|
|
149
|
+
};
|
|
150
|
+
var n = discreteUniform( 10, 0, 100, opts );
|
|
151
|
+
var p = uniform( 10, 0.0, 1.0, opts );
|
|
150
152
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
logEachMap( 'n: %0.4f, p: %0.4f, Kurt(X;n,p): %0.4f', n, p, kurtosis );
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
</section>
|
|
157
|
+
|
|
158
|
+
<!-- /.examples -->
|
|
159
|
+
|
|
160
|
+
<!-- C interface documentation. -->
|
|
161
|
+
|
|
162
|
+
<section class="c">
|
|
163
|
+
|
|
164
|
+
## C APIs
|
|
165
|
+
|
|
166
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
167
|
+
|
|
168
|
+
<section class="intro">
|
|
169
|
+
|
|
170
|
+
</section>
|
|
171
|
+
|
|
172
|
+
<!-- /.intro -->
|
|
173
|
+
|
|
174
|
+
<!-- C usage documentation. -->
|
|
175
|
+
|
|
176
|
+
<section class="usage">
|
|
177
|
+
|
|
178
|
+
### Usage
|
|
179
|
+
|
|
180
|
+
```c
|
|
181
|
+
#include "stdlib/stats/base/dists/binomial/kurtosis.h"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### stdlib_base_dists_binomial_kurtosis( n, p )
|
|
185
|
+
|
|
186
|
+
Returns the [excess kurtosis][kurtosis] of a [binomial][binomial-distribution] distribution with number of trials `n` and success probability `p`.
|
|
187
|
+
|
|
188
|
+
```c
|
|
189
|
+
double out = stdlib_base_dists_binomial_kurtosis( 100, 0.1 );
|
|
190
|
+
// returns ~0.051
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The function accepts the following arguments:
|
|
194
|
+
|
|
195
|
+
- **n**: `[in] int32_t` number of trials.
|
|
196
|
+
- **p**: `[in] double` success probability.
|
|
197
|
+
|
|
198
|
+
```c
|
|
199
|
+
double stdlib_base_dists_binomial_kurtosis( const int32_t n, const double p );
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
</section>
|
|
203
|
+
|
|
204
|
+
<!-- /.usage -->
|
|
205
|
+
|
|
206
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
207
|
+
|
|
208
|
+
<section class="notes">
|
|
209
|
+
|
|
210
|
+
</section>
|
|
211
|
+
|
|
212
|
+
<!-- /.notes -->
|
|
213
|
+
|
|
214
|
+
<!-- C API usage examples. -->
|
|
215
|
+
|
|
216
|
+
<section class="examples">
|
|
217
|
+
|
|
218
|
+
### Examples
|
|
219
|
+
|
|
220
|
+
```c
|
|
221
|
+
#include "stdlib/stats/base/dists/binomial/kurtosis.h"
|
|
222
|
+
#include "stdlib/math/base/special/ceil.h"
|
|
223
|
+
#include <stdlib.h>
|
|
224
|
+
#include <stdint.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
|
+
int32_t n;
|
|
234
|
+
double p;
|
|
235
|
+
double y;
|
|
236
|
+
int i;
|
|
237
|
+
|
|
238
|
+
for ( i = 0; i < 25; i++ ) {
|
|
239
|
+
n = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) );
|
|
240
|
+
p = random_uniform( 0.0, 1.0 );
|
|
241
|
+
y = stdlib_base_dists_binomial_kurtosis( n, p );
|
|
242
|
+
printf( "n: %d, p: %lf, Kurt(X;n,p): %lf\n", n, p, y );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return 0;
|
|
156
246
|
}
|
|
157
247
|
```
|
|
158
248
|
|
|
@@ -160,6 +250,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
160
250
|
|
|
161
251
|
<!-- /.examples -->
|
|
162
252
|
|
|
253
|
+
</section>
|
|
254
|
+
|
|
255
|
+
<!-- /.c -->
|
|
256
|
+
|
|
163
257
|
<!-- 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. -->
|
|
164
258
|
|
|
165
259
|
<section class="references">
|
|
@@ -202,7 +296,7 @@ See [LICENSE][stdlib-license].
|
|
|
202
296
|
|
|
203
297
|
## Copyright
|
|
204
298
|
|
|
205
|
-
Copyright © 2016-
|
|
299
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
206
300
|
|
|
207
301
|
</section>
|
|
208
302
|
|
|
@@ -215,8 +309,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
215
309
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-binomial-kurtosis.svg
|
|
216
310
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-binomial-kurtosis
|
|
217
311
|
|
|
218
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-binomial-kurtosis/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
219
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-binomial-kurtosis/actions/workflows/test.yml?query=branch:v0.
|
|
312
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-binomial-kurtosis/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
313
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-binomial-kurtosis/actions/workflows/test.yml?query=branch:v0.3.0
|
|
220
314
|
|
|
221
315
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-binomial-kurtosis/main.svg
|
|
222
316
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-binomial-kurtosis?branch=main
|
|
@@ -228,8 +322,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
228
322
|
|
|
229
323
|
-->
|
|
230
324
|
|
|
231
|
-
[chat-image]: https://img.shields.io/
|
|
232
|
-
[chat-url]: https://
|
|
325
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
326
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
233
327
|
|
|
234
328
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
235
329
|
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\n\n\n// MAIN //\n\n/**\n* Returns the kurtosis of a binomial distribution.\n*\n* @param {NonNegativeInteger} n - number of trials\n* @param {Probability} p - success probability\n* @returns {number} excess kurtosis\n*\n* @example\n* var v = kurtosis( 100, 0.1 );\n* // returns ~0.051\n*\n* @example\n* var v = kurtosis( 20, 0.5 );\n* // returns ~-0.1\n*\n* @example\n* var v = kurtosis( 10.3, 0.5 );\n* // returns NaN\n*\n* @example\n* var v = kurtosis( 20, 1.1 );\n* // returns NaN\n*\n* @example\n* var v = kurtosis( 20, NaN );\n* // returns NaN\n*/\nfunction kurtosis( n, p ) {\n\tvar pq;\n\tif (\n\t\tisnan( n ) ||\n\t\tisnan( p ) ||\n\t\tp < 0.0 ||\n\t\tp > 1.0 ||\n\t\t!isNonNegativeInteger( n ) ||\n\t\tn === PINF\n\t) {\n\t\treturn NaN;\n\t}\n\tpq = p * ( 1.0 - p );\n\treturn ( 1.0 - ( 6.0 * pq ) ) / ( n * pq );\n}\n\n\n// EXPORTS //\n\nmodule.exports = kurtosis;\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* Binomial distribution excess kurtosis.\n*\n* @module @stdlib/stats-base-dists-binomial-kurtosis\n*\n* @example\n* var kurtosis = require( '@stdlib/stats-base-dists-binomial-kurtosis' );\n*\n* var v = kurtosis( 100, 0.1 );\n* // returns ~0.051\n*\n* v = kurtosis( 20, 0.5 );\n* // returns ~-0.1\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\n\n\n// MAIN //\n\n/**\n* Returns the excess kurtosis of a binomial distribution.\n*\n* @param {NonNegativeInteger} n - number of trials\n* @param {Probability} p - success probability\n* @returns {number} excess kurtosis\n*\n* @example\n* var v = kurtosis( 100, 0.1 );\n* // returns ~0.051\n*\n* @example\n* var v = kurtosis( 20, 0.5 );\n* // returns ~-0.1\n*\n* @example\n* var v = kurtosis( 10.3, 0.5 );\n* // returns NaN\n*\n* @example\n* var v = kurtosis( 20, 1.1 );\n* // returns NaN\n*\n* @example\n* var v = kurtosis( 20, NaN );\n* // returns NaN\n*/\nfunction kurtosis( n, p ) {\n\tvar pq;\n\tif (\n\t\tisnan( n ) ||\n\t\tisnan( p ) ||\n\t\tp < 0.0 ||\n\t\tp > 1.0 ||\n\t\t!isNonNegativeInteger( n ) ||\n\t\tn === PINF\n\t) {\n\t\treturn NaN;\n\t}\n\tpq = p * ( 1.0 - p );\n\treturn ( 1.0 - ( 6.0 * pq ) ) / ( n * pq );\n}\n\n\n// EXPORTS //\n\nmodule.exports = kurtosis;\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* Binomial distribution excess kurtosis.\n*\n* @module @stdlib/stats-base-dists-binomial-kurtosis\n*\n* @example\n* var kurtosis = require( '@stdlib/stats-base-dists-binomial-kurtosis' );\n*\n* var v = kurtosis( 100, 0.1 );\n* // returns ~0.051\n*\n* v = kurtosis( 20, 0.5 );\n* // returns ~-0.1\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
5
|
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,iDAAkD,EAClFC,EAAQ,QAAS,iCAAkC,EACnDC,EAAO,QAAS,gCAAiC,EAgCrD,SAASC,EAAUC,EAAGC,EAAI,CACzB,IAAIC,EACJ,OACCL,EAAOG,CAAE,GACTH,EAAOI,CAAE,GACTA,EAAI,GACJA,EAAI,GACJ,CAACL,EAAsBI,CAAE,GACzBA,IAAMF,EAEC,KAERI,EAAKD,GAAM,EAAMA,IACR,EAAQ,EAAMC,IAAWF,EAAIE,GACvC,CAKAP,EAAO,QAAUI,ICtCjB,IAAII,EAAO,IAKX,OAAO,QAAUA",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isnan", "PINF", "kurtosis", "n", "p", "pq", "main"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
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_BINOMIAL_KURTOSIS_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_BINOMIAL_KURTOSIS_H
|
|
21
|
+
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
26
|
+
*/
|
|
27
|
+
#ifdef __cplusplus
|
|
28
|
+
extern "C" {
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the excess kurtosis of a binomial distribution with number of trials `n` and success probability `p`.
|
|
33
|
+
*/
|
|
34
|
+
double stdlib_base_dists_binomial_kurtosis( const int32_t n, const double p );
|
|
35
|
+
|
|
36
|
+
#ifdef __cplusplus
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#endif // !STDLIB_STATS_BASE_DISTS_BINOMIAL_KURTOSIS_H
|
package/lib/main.js
CHANGED
|
@@ -28,7 +28,7 @@ var PINF = require( '@stdlib/constants-float64-pinf' );
|
|
|
28
28
|
// MAIN //
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Returns the kurtosis of a binomial distribution.
|
|
31
|
+
* Returns the excess kurtosis of a binomial distribution.
|
|
32
32
|
*
|
|
33
33
|
* @param {NonNegativeInteger} n - number of trials
|
|
34
34
|
* @param {Probability} p - success probability
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
* Returns the excess kurtosis of a binomial distribution with number of trials `n` and success probability `p`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {NonNegativeInteger} n - number of trials
|
|
33
|
+
* @param {Probability} p - success probability
|
|
34
|
+
* @returns {number} excess kurtosis
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var v = kurtosis( 100, 0.1 );
|
|
38
|
+
* // returns ~0.051
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var v = kurtosis( 20, 0.5 );
|
|
42
|
+
* // returns ~-0.1
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var v = kurtosis( 20, 1.1 );
|
|
46
|
+
* // returns NaN
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var v = kurtosis( 20, NaN );
|
|
50
|
+
* // returns NaN
|
|
51
|
+
*/
|
|
52
|
+
function kurtosis( n, p ) {
|
|
53
|
+
return addon( n, p );
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// EXPORTS //
|
|
58
|
+
|
|
59
|
+
module.exports = kurtosis;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"task": "benchmark",
|
|
47
|
+
"wasm": false,
|
|
48
|
+
"src": [
|
|
49
|
+
"./src/main.c"
|
|
50
|
+
],
|
|
51
|
+
"include": [
|
|
52
|
+
"./include"
|
|
53
|
+
],
|
|
54
|
+
"libraries": [],
|
|
55
|
+
"libpath": [],
|
|
56
|
+
"dependencies": [
|
|
57
|
+
"@stdlib/math-base-assert-is-nan",
|
|
58
|
+
"@stdlib/math-base-special-ceil"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"task": "examples",
|
|
63
|
+
"wasm": false,
|
|
64
|
+
"src": [
|
|
65
|
+
"./src/main.c"
|
|
66
|
+
],
|
|
67
|
+
"include": [
|
|
68
|
+
"./include"
|
|
69
|
+
],
|
|
70
|
+
"libraries": [],
|
|
71
|
+
"libpath": [],
|
|
72
|
+
"dependencies": [
|
|
73
|
+
"@stdlib/math-base-assert-is-nan",
|
|
74
|
+
"@stdlib/math-base-special-ceil"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-binomial-kurtosis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Binomial distribution excess kurtosis.",
|
|
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,7 +35,9 @@
|
|
|
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-assert-is-nonnegative-integer": "^0.2.
|
|
38
|
+
"@stdlib/math-base-assert-is-nonnegative-integer": "^0.2.2",
|
|
39
|
+
"@stdlib/math-base-napi-binary": "^0.3.1",
|
|
40
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {},
|
|
38
43
|
"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/binomial/kurtosis.h"
|
|
20
|
+
#include "stdlib/math/base/napi/binary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ID_D( stdlib_base_dists_binomial_kurtosis );
|
package/src/main.c
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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/binomial/kurtosis.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include <stdint.h>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the excess kurtosis of a binomial distribution with number of trials `n` and success probability `p`.
|
|
25
|
+
*
|
|
26
|
+
* @param n number of trials
|
|
27
|
+
* @param p success probability
|
|
28
|
+
* @return excess kurtosis
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* double y = stdlib_base_dists_binomial_kurtosis( 100, 0.1 );
|
|
32
|
+
* // returns ~0.051
|
|
33
|
+
*/
|
|
34
|
+
double stdlib_base_dists_binomial_kurtosis( const int32_t n, const double p ) {
|
|
35
|
+
if (
|
|
36
|
+
stdlib_base_is_nan( p ) ||
|
|
37
|
+
n < 0 ||
|
|
38
|
+
p < 0.0 ||
|
|
39
|
+
p > 1.0
|
|
40
|
+
) {
|
|
41
|
+
return 0.0 / 0.0;
|
|
42
|
+
}
|
|
43
|
+
const double pq = p * ( 1.0 - p );
|
|
44
|
+
return ( 1.0 - ( 6.0 * pq ) ) / ( (double)n * pq );
|
|
45
|
+
}
|