@stdlib/stats-base-dists-t-stdev 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 +104 -15
- package/dist/index.js.map +1 -1
- package/include/stdlib/stats/base/dists/t/stdev.h +38 -0
- package/lib/index.js +1 -1
- package/lib/native.js +62 -0
- package/manifest.json +82 -0
- package/package.json +7 -2
- package/src/addon.c +22 -0
- package/src/main.c +42 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ limitations under the License.
|
|
|
33
33
|
|
|
34
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
35
|
|
|
36
|
-
> [Student's t][t-distribution] distribution [
|
|
36
|
+
> [Student's t][t-distribution] distribution [standard deviation][standard-deviation].
|
|
37
37
|
|
|
38
38
|
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
39
39
|
|
|
@@ -129,18 +129,103 @@ y = stdev( 0.8 );
|
|
|
129
129
|
<!-- eslint no-undef: "error" -->
|
|
130
130
|
|
|
131
131
|
```javascript
|
|
132
|
-
var
|
|
133
|
-
var
|
|
132
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
133
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
134
134
|
var stdev = require( '@stdlib/stats-base-dists-t-stdev' );
|
|
135
135
|
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
var opts = {
|
|
137
|
+
'dtype': 'float64'
|
|
138
|
+
};
|
|
139
|
+
var v = uniform( 10, 0.0, 20.0, opts );
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
logEachMap( 'v: %0.4f, SD(X;v): %0.4f', v, stdev );
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</section>
|
|
145
|
+
|
|
146
|
+
<!-- /.examples -->
|
|
147
|
+
|
|
148
|
+
<!-- C interface documentation. -->
|
|
149
|
+
|
|
150
|
+
* * *
|
|
151
|
+
|
|
152
|
+
<section class="c">
|
|
153
|
+
|
|
154
|
+
## C APIs
|
|
155
|
+
|
|
156
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
157
|
+
|
|
158
|
+
<section class="intro">
|
|
159
|
+
|
|
160
|
+
</section>
|
|
161
|
+
|
|
162
|
+
<!-- /.intro -->
|
|
163
|
+
|
|
164
|
+
<!-- C usage documentation. -->
|
|
165
|
+
|
|
166
|
+
<section class="usage">
|
|
167
|
+
|
|
168
|
+
### Usage
|
|
169
|
+
|
|
170
|
+
```c
|
|
171
|
+
#include "stdlib/stats/base/dists/t/stdev.h"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### stdlib_base_dists_t_stdev( v )
|
|
175
|
+
|
|
176
|
+
Returns the standard deviation of a Student's t distribution.
|
|
177
|
+
|
|
178
|
+
```c
|
|
179
|
+
double out = stdlib_base_dists_t_stdev( 9.0 );
|
|
180
|
+
// returns ~1.134
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The function accepts the following arguments:
|
|
184
|
+
|
|
185
|
+
- **v**: `[in] double` degrees of freedom.
|
|
186
|
+
|
|
187
|
+
```c
|
|
188
|
+
double stdlib_base_dists_t_stdev( const double v );
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
</section>
|
|
192
|
+
|
|
193
|
+
<!-- /.usage -->
|
|
194
|
+
|
|
195
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
196
|
+
|
|
197
|
+
<section class="notes">
|
|
198
|
+
|
|
199
|
+
</section>
|
|
200
|
+
|
|
201
|
+
<!-- /.notes -->
|
|
202
|
+
|
|
203
|
+
<!-- C API usage examples. -->
|
|
204
|
+
|
|
205
|
+
<section class="examples">
|
|
206
|
+
|
|
207
|
+
### Examples
|
|
208
|
+
|
|
209
|
+
```c
|
|
210
|
+
#include "stdlib/stats/base/dists/t/stdev.h"
|
|
211
|
+
#include <stdlib.h>
|
|
212
|
+
#include <stdio.h>
|
|
213
|
+
|
|
214
|
+
static double random_uniform( const double min, const double max ) {
|
|
215
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
216
|
+
return min + ( v*(max-min) );
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
int main( void ) {
|
|
220
|
+
double v;
|
|
221
|
+
double y;
|
|
222
|
+
int i;
|
|
223
|
+
|
|
224
|
+
for ( i = 0; i < 25; i++ ) {
|
|
225
|
+
v = random_uniform( 0.0, 20.0 );
|
|
226
|
+
y = stdlib_base_dists_t_stdev( v );
|
|
227
|
+
printf( "v: %lf, SD(X;v): %lf\n", v, y );
|
|
228
|
+
}
|
|
144
229
|
}
|
|
145
230
|
```
|
|
146
231
|
|
|
@@ -148,6 +233,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
148
233
|
|
|
149
234
|
<!-- /.examples -->
|
|
150
235
|
|
|
236
|
+
</section>
|
|
237
|
+
|
|
238
|
+
<!-- /.c -->
|
|
239
|
+
|
|
151
240
|
<!-- 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. -->
|
|
152
241
|
|
|
153
242
|
<section class="references">
|
|
@@ -190,7 +279,7 @@ See [LICENSE][stdlib-license].
|
|
|
190
279
|
|
|
191
280
|
## Copyright
|
|
192
281
|
|
|
193
|
-
Copyright © 2016-
|
|
282
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
194
283
|
|
|
195
284
|
</section>
|
|
196
285
|
|
|
@@ -203,8 +292,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
203
292
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-t-stdev.svg
|
|
204
293
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-t-stdev
|
|
205
294
|
|
|
206
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-t-stdev/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
207
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-t-stdev/actions/workflows/test.yml?query=branch:v0.
|
|
295
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-t-stdev/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
296
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-t-stdev/actions/workflows/test.yml?query=branch:v0.3.0
|
|
208
297
|
|
|
209
298
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-t-stdev/main.svg
|
|
210
299
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-t-stdev?branch=main
|
|
@@ -216,8 +305,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
216
305
|
|
|
217
306
|
-->
|
|
218
307
|
|
|
219
|
-
[chat-image]: https://img.shields.io/
|
|
220
|
-
[chat-url]: https://
|
|
308
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
309
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
221
310
|
|
|
222
311
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
223
312
|
|
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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\n\n\n// MAIN //\n\n/**\n* Returns the standard deviation of a Student's t distribution.\n*\n* @param {PositiveNumber} v - degrees of freedom\n* @returns {PositiveNumber} standard deviation\n*\n* @example\n* var v = stdev( 9.0 );\n* // returns ~1.134\n*\n* @example\n* var v = stdev( 2.0 );\n* // returns Infinity\n*\n* @example\n* var v = stdev( 0.5 );\n* // returns NaN\n*\n* @example\n* var v = stdev( -0.2 );\n* // returns NaN\n*\n* @example\n* var v = stdev( NaN );\n* // returns NaN\n*/\nfunction stdev( v ) {\n\tif ( isnan( v ) || v <= 1.0 ) {\n\t\treturn NaN;\n\t}\n\tif ( v <= 2.0 ) {\n\t\treturn PINF;\n\t}\n\treturn sqrt( v / ( v - 2.0 ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = stdev;\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* Student's t distribution standard deviation.\n*\n* @module @stdlib/stats-base-dists-t-stdev\n*\n* @example\n* var stdev = require( '@stdlib/stats-base-dists-t-stdev' );\n*\n* var v = stdev( 11.0 );\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 sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\n\n\n// MAIN //\n\n/**\n* Returns the standard deviation of a Student's t distribution.\n*\n* @param {PositiveNumber} v - degrees of freedom\n* @returns {PositiveNumber} standard deviation\n*\n* @example\n* var v = stdev( 9.0 );\n* // returns ~1.134\n*\n* @example\n* var v = stdev( 2.0 );\n* // returns Infinity\n*\n* @example\n* var v = stdev( 0.5 );\n* // returns NaN\n*\n* @example\n* var v = stdev( -0.2 );\n* // returns NaN\n*\n* @example\n* var v = stdev( NaN );\n* // returns NaN\n*/\nfunction stdev( v ) {\n\tif ( isnan( v ) || v <= 1.0 ) {\n\t\treturn NaN;\n\t}\n\tif ( v <= 2.0 ) {\n\t\treturn PINF;\n\t}\n\treturn sqrt( v / ( v - 2.0 ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = stdev;\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* Student's t distribution standard deviation.\n*\n* @module @stdlib/stats-base-dists-t-stdev\n*\n* @example\n* var stdev = require( '@stdlib/stats-base-dists-t-stdev' );\n*\n* var v = stdev( 11.0 );\n* // returns ~1.106\n*\n* v = stdev( 4.5 );\n* // returns ~1.342\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,EAAQ,QAAS,iCAAkC,EACnDC,EAAO,QAAS,gCAAiC,EACjDC,EAAO,QAAS,gCAAiC,EA+BrD,SAASC,EAAOC,EAAI,CACnB,OAAKJ,EAAOI,CAAE,GAAKA,GAAK,EAChB,IAEHA,GAAK,EACFF,EAEDD,EAAMG,GAAMA,EAAI,EAAM,CAC9B,CAKAL,EAAO,QAAUI,IC/BjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "sqrt", "PINF", "stdev", "v", "main"]
|
|
7
7
|
}
|
|
@@ -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_STDEV_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_T_STDEV_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 standard deviation of a Student's t distribution.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_t_stdev( const double v );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_T_STDEV_H
|
package/lib/index.js
CHANGED
package/lib/native.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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 standard deviation of a Student's t distribution.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {PositiveNumber} v - degrees of freedom
|
|
33
|
+
* @returns {PositiveNumber} standard deviation
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var v = stdev( 9.0 );
|
|
37
|
+
* // returns ~1.134
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* var v = stdev( 2.0 );
|
|
41
|
+
* // returns Infinity
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* var v = stdev( 0.5 );
|
|
45
|
+
* // returns NaN
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var v = stdev( -0.2 );
|
|
49
|
+
* // returns NaN
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* var v = stdev( NaN );
|
|
53
|
+
* // returns NaN
|
|
54
|
+
*/
|
|
55
|
+
function stdev( v ) {
|
|
56
|
+
return addon( v );
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// EXPORTS //
|
|
61
|
+
|
|
62
|
+
module.exports = stdev;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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/math-base-special-sqrt",
|
|
44
|
+
"@stdlib/constants-float64-pinf"
|
|
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-sqrt",
|
|
61
|
+
"@stdlib/constants-float64-pinf"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"task": "examples",
|
|
66
|
+
"wasm": false,
|
|
67
|
+
"src": [
|
|
68
|
+
"./src/main.c"
|
|
69
|
+
],
|
|
70
|
+
"include": [
|
|
71
|
+
"./include"
|
|
72
|
+
],
|
|
73
|
+
"libraries": [],
|
|
74
|
+
"libpath": [],
|
|
75
|
+
"dependencies": [
|
|
76
|
+
"@stdlib/math-base-assert-is-nan",
|
|
77
|
+
"@stdlib/math-base-special-sqrt",
|
|
78
|
+
"@stdlib/constants-float64-pinf"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-t-stdev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Student's t distribution standard deviation.",
|
|
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-
|
|
38
|
+
"@stdlib/math-base-napi-unary": "^0.2.4",
|
|
39
|
+
"@stdlib/math-base-special-sqrt": "^0.2.2",
|
|
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) 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/stdev.h"
|
|
20
|
+
#include "stdlib/math/base/napi/unary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_t_stdev )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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/stdev.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/math/base/special/sqrt.h"
|
|
22
|
+
#include "stdlib/constants/float64/pinf.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns the standard deviation of a Student's t distribution.
|
|
26
|
+
*
|
|
27
|
+
* @param v degrees of freedom
|
|
28
|
+
* @return standard deviation
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* double y = stdlib_base_dists_t_stdev( 9.0 );
|
|
32
|
+
* // returns ~1.134
|
|
33
|
+
*/
|
|
34
|
+
double stdlib_base_dists_t_stdev( const double v ) {
|
|
35
|
+
if ( stdlib_base_is_nan( v ) || v <= 1.0 ) {
|
|
36
|
+
return 0.0 / 0.0; // NaN
|
|
37
|
+
}
|
|
38
|
+
if ( v <= 2.0 ) {
|
|
39
|
+
return STDLIB_CONSTANT_FLOAT64_PINF;
|
|
40
|
+
}
|
|
41
|
+
return stdlib_base_sqrt( v / ( v - 2.0 ) );
|
|
42
|
+
}
|