@stdlib/stats-base-dists-t-kurtosis 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -135,18 +135,103 @@ y = kurtosis( 2.0 );
135
135
  <!-- eslint no-undef: "error" -->
136
136
 
137
137
  ```javascript
138
- var randu = require( '@stdlib/random-base-randu' );
139
- var round = require( '@stdlib/math-base-special-round' );
138
+ var uniform = require( '@stdlib/random-array-uniform' );
139
+ var logEachMap = require( '@stdlib/console-log-each-map' );
140
140
  var kurtosis = require( '@stdlib/stats-base-dists-t-kurtosis' );
141
141
 
142
- var v;
143
- var y;
144
- var i;
142
+ var opts = {
143
+ 'dtype': 'float64'
144
+ };
145
+ var v = uniform( 10, 0.0, 20.0, opts );
145
146
 
146
- for ( i = 0; i < 10; i++ ) {
147
- v = randu() * 20.0;
148
- y = kurtosis( v );
149
- console.log( 'v: %d, Kurt(X,v): %d', v.toFixed( 4 ), y.toFixed( 4 ) );
147
+ logEachMap( 'v: %0.4f, Kurt(X;v): %0.4f', v, kurtosis );
148
+ ```
149
+
150
+ </section>
151
+
152
+ <!-- /.examples -->
153
+
154
+ <!-- C interface documentation. -->
155
+
156
+ * * *
157
+
158
+ <section class="c">
159
+
160
+ ## C APIs
161
+
162
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
163
+
164
+ <section class="intro">
165
+
166
+ </section>
167
+
168
+ <!-- /.intro -->
169
+
170
+ <!-- C usage documentation. -->
171
+
172
+ <section class="usage">
173
+
174
+ ### Usage
175
+
176
+ ```c
177
+ #include "stdlib/stats/base/dists/t/kurtosis.h"
178
+ ```
179
+
180
+ #### stdlib_base_dists_t_kurtosis( v )
181
+
182
+ Returns the excess kurtosis of a Student's t distribution.
183
+
184
+ ```c
185
+ double out = stdlib_base_dists_t_kurtosis( 9.0 );
186
+ // returns 1.2
187
+ ```
188
+
189
+ The function accepts the following arguments:
190
+
191
+ - **v**: `[in] double` degrees of freedom.
192
+
193
+ ```c
194
+ double stdlib_base_dists_t_kurtosis( const double v );
195
+ ```
196
+
197
+ </section>
198
+
199
+ <!-- /.usage -->
200
+
201
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
202
+
203
+ <section class="notes">
204
+
205
+ </section>
206
+
207
+ <!-- /.notes -->
208
+
209
+ <!-- C API usage examples. -->
210
+
211
+ <section class="examples">
212
+
213
+ ### Examples
214
+
215
+ ```c
216
+ #include "stdlib/stats/base/dists/t/kurtosis.h"
217
+ #include <stdlib.h>
218
+ #include <stdio.h>
219
+
220
+ static double random_uniform( const double min, const double max ) {
221
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
222
+ return min + ( v*(max-min) );
223
+ }
224
+
225
+ int main( void ) {
226
+ double v;
227
+ double y;
228
+ int i;
229
+
230
+ for ( i = 0; i < 25; i++ ) {
231
+ v = random_uniform( 0.0, 20.0 );
232
+ y = stdlib_base_dists_t_kurtosis( v );
233
+ printf( "v: %lf, Kurt(X;v): %lf\n", v, y );
234
+ }
150
235
  }
151
236
  ```
152
237
 
@@ -154,6 +239,10 @@ for ( i = 0; i < 10; i++ ) {
154
239
 
155
240
  <!-- /.examples -->
156
241
 
242
+ </section>
243
+
244
+ <!-- /.c -->
245
+
157
246
  <!-- 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. -->
158
247
 
159
248
  <section class="references">
@@ -196,7 +285,7 @@ See [LICENSE][stdlib-license].
196
285
 
197
286
  ## Copyright
198
287
 
199
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
288
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
200
289
 
201
290
  </section>
202
291
 
@@ -209,8 +298,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
209
298
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-t-kurtosis.svg
210
299
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-t-kurtosis
211
300
 
212
- [test-image]: https://github.com/stdlib-js/stats-base-dists-t-kurtosis/actions/workflows/test.yml/badge.svg?branch=v0.2.1
213
- [test-url]: https://github.com/stdlib-js/stats-base-dists-t-kurtosis/actions/workflows/test.yml?query=branch:v0.2.1
301
+ [test-image]: https://github.com/stdlib-js/stats-base-dists-t-kurtosis/actions/workflows/test.yml/badge.svg?branch=v0.3.0
302
+ [test-url]: https://github.com/stdlib-js/stats-base-dists-t-kurtosis/actions/workflows/test.yml?query=branch:v0.3.0
214
303
 
215
304
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-t-kurtosis/main.svg
216
305
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-t-kurtosis?branch=main
@@ -222,8 +311,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
222
311
 
223
312
  -->
224
313
 
225
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
226
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
314
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
315
+ [chat-url]: https://stdlib.zulipchat.com
227
316
 
228
317
  [stdlib]: https://github.com/stdlib-js/stdlib
229
318
 
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 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_T_KURTOSIS_H
20
+ #define STDLIB_STATS_BASE_DISTS_T_KURTOSIS_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
+ * Returns the excess kurtosis of a Student's t distribution.
31
+ */
32
+ double stdlib_base_dists_t_kurtosis( const double v );
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif // !STDLIB_STATS_BASE_DISTS_T_KURTOSIS_H
package/lib/native.js ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 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 Student's t distribution.
30
+ *
31
+ * @private
32
+ * @param {NonNegativeNumber} v - degrees of freedom
33
+ * @returns {NonNegativeNumber} excess kurtosis
34
+ *
35
+ * @example
36
+ * var v = kurtosis( 9.0 );
37
+ * // returns 1.2
38
+ *
39
+ * @example
40
+ * var v = kurtosis( 5.0 );
41
+ * // returns 6.0
42
+ *
43
+ * @example
44
+ * var v = kurtosis( 3.0 );
45
+ * // returns Infinity
46
+ *
47
+ * @example
48
+ * var v = kurtosis( 0.5 );
49
+ * // returns NaN
50
+ *
51
+ * @example
52
+ * var v = kurtosis( -0.2 );
53
+ * // returns NaN
54
+ *
55
+ * @example
56
+ * var v = kurtosis( NaN );
57
+ * // returns NaN
58
+ */
59
+ function kurtosis( v ) {
60
+ return addon( v );
61
+ }
62
+
63
+
64
+ // EXPORTS //
65
+
66
+ module.exports = kurtosis;
package/manifest.json ADDED
@@ -0,0 +1,79 @@
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-unary",
42
+ "@stdlib/math-base-assert-is-nan",
43
+ "@stdlib/constants-float64-pinf"
44
+ ]
45
+ },
46
+ {
47
+ "task": "benchmark",
48
+ "wasm": false,
49
+ "src": [
50
+ "./src/main.c"
51
+ ],
52
+ "include": [
53
+ "./include"
54
+ ],
55
+ "libraries": [],
56
+ "libpath": [],
57
+ "dependencies": [
58
+ "@stdlib/math-base-assert-is-nan",
59
+ "@stdlib/constants-float64-pinf"
60
+ ]
61
+ },
62
+ {
63
+ "task": "examples",
64
+ "wasm": false,
65
+ "src": [
66
+ "./src/main.c"
67
+ ],
68
+ "include": [
69
+ "./include"
70
+ ],
71
+ "libraries": [],
72
+ "libpath": [],
73
+ "dependencies": [
74
+ "@stdlib/math-base-assert-is-nan",
75
+ "@stdlib/constants-float64-pinf"
76
+ ]
77
+ }
78
+ ]
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-dists-t-kurtosis",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Student's t 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",
@@ -30,8 +33,10 @@
30
33
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
34
  },
32
35
  "dependencies": {
33
- "@stdlib/constants-float64-pinf": "^0.2.1",
34
- "@stdlib/math-base-assert-is-nan": "^0.2.1"
36
+ "@stdlib/constants-float64-pinf": "^0.2.2",
37
+ "@stdlib/math-base-assert-is-nan": "^0.2.2",
38
+ "@stdlib/math-base-napi-unary": "^0.2.4",
39
+ "@stdlib/utils-library-manifest": "^0.2.3"
35
40
  },
36
41
  "devDependencies": {},
37
42
  "engines": {
package/src/addon.c ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 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/t/kurtosis.h"
20
+ #include "stdlib/math/base/napi/unary.h"
21
+
22
+ STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_t_kurtosis )
package/src/main.c ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 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/t/kurtosis.h"
20
+ #include "stdlib/math/base/assert/is_nan.h"
21
+ #include "stdlib/constants/float64/pinf.h"
22
+
23
+ /**
24
+ * Returns the excess kurtosis of a Student's t distribution.
25
+ *
26
+ * @param v degrees of freedom
27
+ * @return excess kurtosis
28
+ *
29
+ * @example
30
+ * double y = stdlib_base_dists_t_kurtosis( 9.0 );
31
+ * // returns 1.2
32
+ */
33
+ double stdlib_base_dists_t_kurtosis( const double v ) {
34
+ if ( stdlib_base_is_nan( v ) || v <= 2.0 ) {
35
+ return 0.0/0.0; // NaN
36
+ }
37
+ if ( v <= 4.0 ) {
38
+ return STDLIB_CONSTANT_FLOAT64_PINF;
39
+ }
40
+ return 6.0 / ( v - 4.0 );
41
+ }