@stdlib/stats-base-dists-arcsine-median 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 +107 -15
- package/dist/index.js.map +2 -2
- package/include/stdlib/stats/base/dists/arcsine/median.h +39 -0
- package/lib/main.js +1 -3
- package/lib/native.js +67 -0
- package/manifest.json +71 -0
- package/package.json +8 -2
- package/src/addon.c +22 -0
- package/src/main.c +37 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -132,19 +132,107 @@ y = median( 3.0, 3.0 );
|
|
|
132
132
|
<!-- eslint no-undef: "error" -->
|
|
133
133
|
|
|
134
134
|
```javascript
|
|
135
|
-
var
|
|
135
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
136
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
136
137
|
var median = require( '@stdlib/stats-base-dists-arcsine-median' );
|
|
137
138
|
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var
|
|
139
|
+
var opts = {
|
|
140
|
+
'dtype': 'float64'
|
|
141
|
+
};
|
|
142
|
+
var a = uniform( 25, 0.0, 10.0, opts );
|
|
143
|
+
var b = uniform( a.length, 10.0, 20.0, opts );
|
|
142
144
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
logEachMap( 'a: %0.4f, b: %0.4f, Median(X;a,b): %0.4f', a, b, median );
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
</section>
|
|
149
|
+
|
|
150
|
+
<!-- /.examples -->
|
|
151
|
+
|
|
152
|
+
<!-- C interface documentation. -->
|
|
153
|
+
|
|
154
|
+
* * *
|
|
155
|
+
|
|
156
|
+
<section class="c">
|
|
157
|
+
|
|
158
|
+
## C APIs
|
|
159
|
+
|
|
160
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
161
|
+
|
|
162
|
+
<section class="intro">
|
|
163
|
+
|
|
164
|
+
</section>
|
|
165
|
+
|
|
166
|
+
<!-- /.intro -->
|
|
167
|
+
|
|
168
|
+
<!-- C usage documentation. -->
|
|
169
|
+
|
|
170
|
+
<section class="usage">
|
|
171
|
+
|
|
172
|
+
### Usage
|
|
173
|
+
|
|
174
|
+
```c
|
|
175
|
+
#include "stdlib/stats/base/dists/arcsine/median.h"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### stdlib_base_dists_arcsine_median( a, b )
|
|
179
|
+
|
|
180
|
+
Returns the median of an arcsine distribution.
|
|
181
|
+
|
|
182
|
+
```c
|
|
183
|
+
double out = stdlib_base_dists_arcsine_median( 0.0, 1.0 );
|
|
184
|
+
// returns 0.5
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The function accepts the following arguments:
|
|
188
|
+
|
|
189
|
+
- **a**: `[in] double` minimum support.
|
|
190
|
+
- **b**: `[in] double` maximum support.
|
|
191
|
+
|
|
192
|
+
```c
|
|
193
|
+
double stdlib_base_dists_arcsine_median( const double a, const double b );
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
</section>
|
|
197
|
+
|
|
198
|
+
<!-- /.usage -->
|
|
199
|
+
|
|
200
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
201
|
+
|
|
202
|
+
<section class="notes">
|
|
203
|
+
|
|
204
|
+
</section>
|
|
205
|
+
|
|
206
|
+
<!-- /.notes -->
|
|
207
|
+
|
|
208
|
+
<!-- C API usage examples. -->
|
|
209
|
+
|
|
210
|
+
<section class="examples">
|
|
211
|
+
|
|
212
|
+
### Examples
|
|
213
|
+
|
|
214
|
+
```c
|
|
215
|
+
#include "stdlib/stats/base/dists/arcsine/median.h"
|
|
216
|
+
#include <stdlib.h>
|
|
217
|
+
#include <stdio.h>
|
|
218
|
+
|
|
219
|
+
static double random_uniform( const double min, const double max ) {
|
|
220
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
221
|
+
return min + ( v*(max-min) );
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
int main( void ) {
|
|
225
|
+
double a;
|
|
226
|
+
double b;
|
|
227
|
+
double y;
|
|
228
|
+
int i;
|
|
229
|
+
|
|
230
|
+
for ( i = 0; i < 10; i++ ) {
|
|
231
|
+
a = random_uniform( 0.0, 10.0 );
|
|
232
|
+
b = random_uniform( a, a+10.0 );
|
|
233
|
+
y = stdlib_base_dists_arcsine_median( a, b );
|
|
234
|
+
printf( "a: %lf, b: %lf, Median(X;a,b): %lf\n", a, b, y );
|
|
235
|
+
}
|
|
148
236
|
}
|
|
149
237
|
```
|
|
150
238
|
|
|
@@ -152,6 +240,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
152
240
|
|
|
153
241
|
<!-- /.examples -->
|
|
154
242
|
|
|
243
|
+
</section>
|
|
244
|
+
|
|
245
|
+
<!-- /.c -->
|
|
246
|
+
|
|
155
247
|
<!-- 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. -->
|
|
156
248
|
|
|
157
249
|
<section class="references">
|
|
@@ -194,7 +286,7 @@ See [LICENSE][stdlib-license].
|
|
|
194
286
|
|
|
195
287
|
## Copyright
|
|
196
288
|
|
|
197
|
-
Copyright © 2016-
|
|
289
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
198
290
|
|
|
199
291
|
</section>
|
|
200
292
|
|
|
@@ -207,8 +299,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
207
299
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-arcsine-median.svg
|
|
208
300
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-arcsine-median
|
|
209
301
|
|
|
210
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-arcsine-median/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
211
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-arcsine-median/actions/workflows/test.yml?query=branch:v0.
|
|
302
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-arcsine-median/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
303
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-arcsine-median/actions/workflows/test.yml?query=branch:v0.3.0
|
|
212
304
|
|
|
213
305
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-arcsine-median/main.svg
|
|
214
306
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-arcsine-median?branch=main
|
|
@@ -220,8 +312,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
220
312
|
|
|
221
313
|
-->
|
|
222
314
|
|
|
223
|
-
[chat-image]: https://img.shields.io/
|
|
224
|
-
[chat-url]: https://
|
|
315
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
316
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
225
317
|
|
|
226
318
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
227
319
|
|
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// MAIN //\n\n/**\n* Returns the median of an arcsine distribution.\n*\n* @param {number} a - minimum support\n* @param {number} b - maximum support\n* @returns {number} median\n*\n* @example\n* var v = median( 0.0, 1.0 );\n* // returns 0.5\n*\n* @example\n* var v = median( 4.0, 12.0 );\n* // returns 8.0\n*\n* @example\n* var v = median( -4.0, 4.0 );\n* // returns 0.0\n*\n* @example\n* var v = median( 1.0, -0.1 );\n* // returns NaN\n*\n* @example\n* var v = median( 2.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = median( NaN, 2.0 );\n* // returns NaN\n*/\nfunction median( a, b ) {\n\tif (
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAqDA,SAASC,EAAQC,EAAGC,EAAI,CACvB,
|
|
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// MAIN //\n\n/**\n* Returns the median of an arcsine distribution.\n*\n* @param {number} a - minimum support\n* @param {number} b - maximum support\n* @returns {number} median\n*\n* @example\n* var v = median( 0.0, 1.0 );\n* // returns 0.5\n*\n* @example\n* var v = median( 4.0, 12.0 );\n* // returns 8.0\n*\n* @example\n* var v = median( -4.0, 4.0 );\n* // returns 0.0\n*\n* @example\n* var v = median( 1.0, -0.1 );\n* // returns NaN\n*\n* @example\n* var v = median( 2.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = median( NaN, 2.0 );\n* // returns NaN\n*/\nfunction median( a, b ) {\n\tif ( a >= b ) {\n\t\treturn NaN;\n\t}\n\treturn 0.5 * ( a + b );\n}\n\n\n// EXPORTS //\n\nmodule.exports = median;\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* Arcsine distribution median.\n*\n* @module @stdlib/stats-base-dists-arcsine-median\n*\n* @example\n* var median = require( '@stdlib/stats-base-dists-arcsine-median' );\n*\n* var v = median( 0.0, 1.0 );\n* // returns 0.5\n*\n* v = median( 4.0, 12.0 );\n* // returns 8.0\n*\n* v = median( 2.0, 8.0 );\n* // returns 5.0\n*/\n\n// MODULES //\n\nvar median = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = median;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAqDA,SAASC,EAAQC,EAAGC,EAAI,CACvB,OAAKD,GAAKC,EACF,IAED,IAAQD,EAAIC,EACpB,CAKAH,EAAO,QAAUC,ICvBjB,IAAIG,EAAS,IAKb,OAAO,QAAUA",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "median", "a", "b", "median"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @license Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#ifndef STDLIB_STATS_BASE_DISTS_ARCSINE_MEDIAN_H
|
|
21
|
+
#define STDLIB_STATS_BASE_DISTS_ARCSINE_MEDIAN_H
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
25
|
+
*/
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns the median of an arcsine distribution.
|
|
32
|
+
*/
|
|
33
|
+
double stdlib_base_dists_arcsine_median( const double a, const double b );
|
|
34
|
+
|
|
35
|
+
#ifdef __cplusplus
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#endif // !STDLIB_STATS_BASE_DISTS_ARCSINE_MEDIAN_H
|
package/lib/main.js
CHANGED
package/lib/native.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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 median of an arcsine distribution.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} a - minimum support
|
|
33
|
+
* @param {number} b - maximum support
|
|
34
|
+
* @returns {number} median
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var v = median( 0.0, 1.0 );
|
|
38
|
+
* // returns 0.5
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var v = median( 4.0, 12.0 );
|
|
42
|
+
* // returns 8.0
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var v = median( -4.0, 4.0 );
|
|
46
|
+
* // returns 0.0
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var v = median( 1.0, -0.1 );
|
|
50
|
+
* // returns NaN
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var v = median( 2.0, NaN );
|
|
54
|
+
* // returns NaN
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* var v = median( NaN, 2.0 );
|
|
58
|
+
* // returns NaN
|
|
59
|
+
*/
|
|
60
|
+
function median( a, b ) {
|
|
61
|
+
return addon( a, b );
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// EXPORTS //
|
|
66
|
+
|
|
67
|
+
module.exports = median;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"task": "benchmark",
|
|
46
|
+
"wasm": false,
|
|
47
|
+
"src": [
|
|
48
|
+
"./src/main.c"
|
|
49
|
+
],
|
|
50
|
+
"include": [
|
|
51
|
+
"./include"
|
|
52
|
+
],
|
|
53
|
+
"libraries": [],
|
|
54
|
+
"libpath": [],
|
|
55
|
+
"dependencies": []
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"task": "examples",
|
|
59
|
+
"wasm": false,
|
|
60
|
+
"src": [
|
|
61
|
+
"./src/main.c"
|
|
62
|
+
],
|
|
63
|
+
"include": [
|
|
64
|
+
"./include"
|
|
65
|
+
],
|
|
66
|
+
"libraries": [],
|
|
67
|
+
"libpath": [],
|
|
68
|
+
"dependencies": []
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-arcsine-median",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Arcsine distribution median.",
|
|
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",
|
|
@@ -29,7 +32,10 @@
|
|
|
29
32
|
"bugs": {
|
|
30
33
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
34
|
},
|
|
32
|
-
"dependencies": {
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@stdlib/math-base-napi-binary": "^0.3.0",
|
|
37
|
+
"@stdlib/utils-library-manifest": "^0.2.2"
|
|
38
|
+
},
|
|
33
39
|
"devDependencies": {},
|
|
34
40
|
"engines": {
|
|
35
41
|
"node": ">=0.10.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/arcsine/median.h"
|
|
20
|
+
#include "stdlib/math/base/napi/binary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_arcsine_median );
|
package/src/main.c
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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/arcsine/median.h"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the median of an arcsine distribution.
|
|
23
|
+
*
|
|
24
|
+
* @param a minimum support
|
|
25
|
+
* @param b maximum support
|
|
26
|
+
* @return median
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* double y = stdlib_base_dists_arcsine_median( 0.0, 1.0 );
|
|
30
|
+
* // returns 0.5
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_arcsine_median( const double a, const double b ) {
|
|
33
|
+
if ( a >= b ) {
|
|
34
|
+
return 0.0 / 0.0; // NaN
|
|
35
|
+
}
|
|
36
|
+
return ( a + b ) / 2.0;
|
|
37
|
+
}
|