@stdlib/stats-base-dists-bradford-quantile 0.1.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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +335 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +7 -0
- package/docs/img/equation_bradford_quantile_function.svg +42 -0
- package/docs/types/index.d.ts +132 -0
- package/include/stdlib/stats/base/dists/bradford/quantile.h +38 -0
- package/lib/factory.js +76 -0
- package/lib/index.js +60 -0
- package/lib/main.js +79 -0
- package/lib/native.js +75 -0
- package/manifest.json +83 -0
- package/package.json +79 -0
- package/src/addon.c +22 -0
- package/src/main.c +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
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
|
+
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
# Quantile Function
|
|
33
|
+
|
|
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
|
+
|
|
36
|
+
> [Bradford][bradford-distribution] distribution [quantile function][quantile-function].
|
|
37
|
+
|
|
38
|
+
<section class="intro">
|
|
39
|
+
|
|
40
|
+
The [quantile function][quantile-function] for a [Bradford][bradford-distribution] random variable is
|
|
41
|
+
|
|
42
|
+
<!-- <equation class="equation" label="eq:bradford_quantile_function" align="center" raw="Q(p;c)=\frac{(1+c)^p - 1}{c}" alt="Quantile function for a Bradford distribution."> -->
|
|
43
|
+
|
|
44
|
+
<div class="equation" align="center" data-raw-text="Q(p;c)=\frac{(1+c)^p - 1}{c}" data-equation="eq:bradford_quantile_function">
|
|
45
|
+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/stats/base/dists/bradford/quantile/docs/img/equation_bradford_quantile_function.svg" alt="Quantile function for a Bradford distribution.">
|
|
46
|
+
<br>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<!-- </equation> -->
|
|
50
|
+
|
|
51
|
+
for `0 <= p <= 1`, where `c` is the shape parameter.
|
|
52
|
+
|
|
53
|
+
</section>
|
|
54
|
+
|
|
55
|
+
<!-- /.intro -->
|
|
56
|
+
|
|
57
|
+
<section class="installation">
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install @stdlib/stats-base-dists-bradford-quantile
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
</section>
|
|
66
|
+
|
|
67
|
+
<section class="usage">
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
var quantile = require( '@stdlib/stats-base-dists-bradford-quantile' );
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### quantile( p, c )
|
|
76
|
+
|
|
77
|
+
Evaluates the [quantile function][quantile-function] for a [Bradford][bradford-distribution] distribution with shape parameter `c` at a probability `p`.
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
var y = quantile( 0.1, 0.1 );
|
|
81
|
+
// returns ~0.096
|
|
82
|
+
|
|
83
|
+
y = quantile( 0.5, 5.0 );
|
|
84
|
+
// returns ~0.290
|
|
85
|
+
|
|
86
|
+
y = quantile( 1.0, 10.0 );
|
|
87
|
+
// returns 1.0
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If provided `NaN` as any argument, the function returns `NaN`.
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
var y = quantile( NaN, 1.0 );
|
|
94
|
+
// returns NaN
|
|
95
|
+
|
|
96
|
+
y = quantile( 0.0, NaN );
|
|
97
|
+
// returns NaN
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If provided a probability `p` outside the interval `[0,1]`, the function returns `NaN`.
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
var y = quantile( 2.0, 0.5 );
|
|
104
|
+
// returns NaN
|
|
105
|
+
|
|
106
|
+
y = quantile( -1.0, 0.5 );
|
|
107
|
+
// returns NaN
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If provided a shape parameter `c <= 0`, the function returns `NaN`.
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
var y = quantile( 0.5, 0.0 );
|
|
114
|
+
// returns NaN
|
|
115
|
+
|
|
116
|
+
y = quantile( 0.5, -10.0 );
|
|
117
|
+
// returns NaN
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### quantile.factory( c )
|
|
121
|
+
|
|
122
|
+
Returns a function for evaluating the [quantile function][quantile-function] for a [Bradford][bradford-distribution] distribution with shape parameter `c`.
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
var myquantile = quantile.factory( 5.0 );
|
|
126
|
+
var y = myquantile( 0.4 );
|
|
127
|
+
// returns ~0.210
|
|
128
|
+
|
|
129
|
+
y = myquantile( 0.8 );
|
|
130
|
+
// returns ~0.639
|
|
131
|
+
|
|
132
|
+
y = myquantile( 1.0 );
|
|
133
|
+
// returns 1.0
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
</section>
|
|
137
|
+
|
|
138
|
+
<!-- /.usage -->
|
|
139
|
+
|
|
140
|
+
<section class="examples">
|
|
141
|
+
|
|
142
|
+
## Examples
|
|
143
|
+
|
|
144
|
+
<!-- eslint no-undef: "error" -->
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
148
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
149
|
+
var quantile = require( '@stdlib/stats-base-dists-bradford-quantile' );
|
|
150
|
+
|
|
151
|
+
var opts = {
|
|
152
|
+
'dtype': 'float64'
|
|
153
|
+
};
|
|
154
|
+
var p = uniform( 10, 0.0, 1.0, opts );
|
|
155
|
+
var c = uniform( 10, 0.1, 10.0, opts );
|
|
156
|
+
|
|
157
|
+
logEachMap( 'p: %0.4f, c: %0.4f, Q(p;c): %0.4f', p, c, quantile );
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
</section>
|
|
161
|
+
|
|
162
|
+
<!-- /.examples -->
|
|
163
|
+
|
|
164
|
+
<!-- C interface documentation. -->
|
|
165
|
+
|
|
166
|
+
<section class="c">
|
|
167
|
+
|
|
168
|
+
## C APIs
|
|
169
|
+
|
|
170
|
+
<section class="intro">
|
|
171
|
+
|
|
172
|
+
</section>
|
|
173
|
+
|
|
174
|
+
<!-- /.intro -->
|
|
175
|
+
|
|
176
|
+
<section class="usage">
|
|
177
|
+
|
|
178
|
+
### Usage
|
|
179
|
+
|
|
180
|
+
```c
|
|
181
|
+
#include "stdlib/stats/base/dists/bradford/quantile.h"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### stdlib_base_dists_bradford_quantile( p, c )
|
|
185
|
+
|
|
186
|
+
Returns the quantile function of a Bradford distribution.
|
|
187
|
+
|
|
188
|
+
```c
|
|
189
|
+
double out = stdlib_base_dists_bradford_quantile( 0.5, 5.0 );
|
|
190
|
+
// returns ~0.290
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The function accepts the following arguments:
|
|
194
|
+
|
|
195
|
+
- **p**: `[in] double` input probability.
|
|
196
|
+
- **c**: `[in] double` shape parameter.
|
|
197
|
+
|
|
198
|
+
```c
|
|
199
|
+
double stdlib_base_dists_bradford_quantile( const double p, const double c );
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
</section>
|
|
203
|
+
|
|
204
|
+
<!-- /.usage -->
|
|
205
|
+
|
|
206
|
+
<section class="notes">
|
|
207
|
+
|
|
208
|
+
</section>
|
|
209
|
+
|
|
210
|
+
<!-- /.notes -->
|
|
211
|
+
|
|
212
|
+
<section class="examples">
|
|
213
|
+
|
|
214
|
+
### Examples
|
|
215
|
+
|
|
216
|
+
```c
|
|
217
|
+
#include "stdlib/stats/base/dists/bradford/quantile.h"
|
|
218
|
+
#include <stdlib.h>
|
|
219
|
+
#include <stdio.h>
|
|
220
|
+
|
|
221
|
+
static double random_uniform( const double min, const double max ) {
|
|
222
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
223
|
+
return min + ( v*(max-min) );
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
int main( void ) {
|
|
227
|
+
double p;
|
|
228
|
+
double c;
|
|
229
|
+
double y;
|
|
230
|
+
int i;
|
|
231
|
+
|
|
232
|
+
for ( i = 0; i < 10; i++ ) {
|
|
233
|
+
p = random_uniform( 0.0, 1.0 );
|
|
234
|
+
c = random_uniform( 0.01, 10.0 );
|
|
235
|
+
y = stdlib_base_dists_bradford_quantile( p, c );
|
|
236
|
+
printf( "p: %lf, c: %lf, Q(p;c): %lf\n", p, c, y );
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
</section>
|
|
242
|
+
|
|
243
|
+
<!-- /.examples -->
|
|
244
|
+
|
|
245
|
+
</section>
|
|
246
|
+
|
|
247
|
+
<!-- /.c -->
|
|
248
|
+
|
|
249
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
250
|
+
|
|
251
|
+
<section class="related">
|
|
252
|
+
|
|
253
|
+
</section>
|
|
254
|
+
|
|
255
|
+
<!-- /.related -->
|
|
256
|
+
|
|
257
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
<section class="main-repo" >
|
|
261
|
+
|
|
262
|
+
* * *
|
|
263
|
+
|
|
264
|
+
## Notice
|
|
265
|
+
|
|
266
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
267
|
+
|
|
268
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
269
|
+
|
|
270
|
+
#### Community
|
|
271
|
+
|
|
272
|
+
[![Chat][chat-image]][chat-url]
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
See [LICENSE][stdlib-license].
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
## Copyright
|
|
282
|
+
|
|
283
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
284
|
+
|
|
285
|
+
</section>
|
|
286
|
+
|
|
287
|
+
<!-- /.stdlib -->
|
|
288
|
+
|
|
289
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
290
|
+
|
|
291
|
+
<section class="links">
|
|
292
|
+
|
|
293
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-bradford-quantile.svg
|
|
294
|
+
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-bradford-quantile
|
|
295
|
+
|
|
296
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
297
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/actions/workflows/test.yml?query=branch:v0.1.0
|
|
298
|
+
|
|
299
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-bradford-quantile/main.svg
|
|
300
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-bradford-quantile?branch=main
|
|
301
|
+
|
|
302
|
+
<!--
|
|
303
|
+
|
|
304
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/stats-base-dists-bradford-quantile.svg
|
|
305
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/stats-base-dists-bradford-quantile/main
|
|
306
|
+
|
|
307
|
+
-->
|
|
308
|
+
|
|
309
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
310
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
311
|
+
|
|
312
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
313
|
+
|
|
314
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
315
|
+
|
|
316
|
+
[umd]: https://github.com/umdjs/umd
|
|
317
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
318
|
+
|
|
319
|
+
[deno-url]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/tree/deno
|
|
320
|
+
[deno-readme]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/blob/deno/README.md
|
|
321
|
+
[umd-url]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/tree/umd
|
|
322
|
+
[umd-readme]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/blob/umd/README.md
|
|
323
|
+
[esm-url]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/tree/esm
|
|
324
|
+
[esm-readme]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/blob/esm/README.md
|
|
325
|
+
[branches-url]: https://github.com/stdlib-js/stats-base-dists-bradford-quantile/blob/main/branches.md
|
|
326
|
+
|
|
327
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-base-dists-bradford-quantile/main/LICENSE
|
|
328
|
+
|
|
329
|
+
[bradford-distribution]: https://en.wikipedia.org/wiki/Bradford%27s_law
|
|
330
|
+
|
|
331
|
+
[quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
|
|
332
|
+
|
|
333
|
+
</section>
|
|
334
|
+
|
|
335
|
+
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var a=i(function(F,n){
|
|
2
|
+
var u=require('@stdlib/math-base-assert-is-nan/dist'),f=require('@stdlib/math-base-special-expm1/dist'),N=require('@stdlib/math-base-special-log1p/dist');function c(r,e){return u(e)||u(r)||e<=0||r<0||r>1?NaN:f(r*N(e))/e}n.exports=c
|
|
3
|
+
});var q=i(function(O,s){
|
|
4
|
+
var l=require('@stdlib/utils-constant-function/dist'),o=require('@stdlib/math-base-assert-is-nan/dist'),x=require('@stdlib/math-base-special-expm1/dist'),y=require('@stdlib/math-base-special-log1p/dist');function m(r){if(o(r)||r<=0)return l(NaN);return e;function e(t){return o(t)||t<0||t>1?NaN:x(t*y(r))/r}}s.exports=m
|
|
5
|
+
});var g=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=a(),d=q();g(v,"factory",d);module.exports=v;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/factory.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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 expm1 = require( '@stdlib/math-base-special-expm1' );\nvar log1p = require( '@stdlib/math-base-special-log1p' );\n\n\n// MAIN //\n\n/**\n* Evaluates the quantile function for a Bradford distribution with shape parameter `c` at a probability `p`.\n*\n* @param {Probability} p - input value\n* @param {PositiveNumber} c - shape parameter\n* @returns {NonNegativeNumber} evaluated quantile function\n*\n* @example\n* var y = quantile( 0.1, 0.1 );\n* // returns ~0.096\n*\n* @example\n* var y = quantile( 0.5, 5.0 );\n* // returns ~0.290\n*\n* @example\n* var y = quantile( 1.0, 10.0 );\n* // returns 1.0\n*\n* @example\n* var y = quantile( 0.5, 0.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 2.0, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = quantile( -1.0, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = quantile( NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 1.0, NaN );\n* // returns NaN\n*/\nfunction quantile( p, c ) {\n\tif ( isnan( c ) || isnan( p ) || c <= 0.0 || p < 0.0 || p > 1.0 ) {\n\t\treturn NaN;\n\t}\n\treturn expm1( p * log1p( c ) ) / c;\n}\n\n\n// EXPORTS //\n\nmodule.exports = quantile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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 expm1 = require( '@stdlib/math-base-special-expm1' );\nvar log1p = require( '@stdlib/math-base-special-log1p' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the quantile function for a Bradford distribution with shape parameter `c`.\n*\n* @param {PositiveNumber} c - shape parameter\n* @returns {NonNegativeNumber} quantile function\n*\n* @example\n* var quantile = factory( 5.0 );\n* var y = quantile( 0.4 );\n* // returns ~0.210\n*\n* y = quantile( 0.8 );\n* // returns ~0.639\n*\n* y = quantile( 1.0 );\n* // returns 1.0\n*/\nfunction factory( c ) {\n\tif ( isnan( c ) || c <= 0.0 ) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn quantile;\n\n\t/**\n\t* Evaluates the quantile function for a Bradford distribution.\n\t*\n\t* @private\n\t* @param {Probability} p - input value\n\t* @returns {number} evaluated quantile function\n\t*\n\t* @example\n\t* var y = quantile( 0.3 );\n\t* // returns <number>\n\t*/\n\tfunction quantile( p ) {\n\t\tif ( isnan( p ) || p < 0.0 || p > 1.0 ) {\n\t\t\treturn NaN;\n\t\t}\n\t\treturn expm1( p * log1p( c ) ) / c;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Bradford distribution quantile function.\n*\n* @module @stdlib/stats-base-dists-bradford-quantile\n*\n* @example\n* var quantile = require( '@stdlib/stats-base-dists-bradford-quantile' );\n*\n* var y = quantile( 0.1, 0.1 );\n* // returns ~0.096\n*\n* var y = quantile( 0.5, 5.0 );\n* // returns ~0.290\n*\n* var myquantile = quantile.factory( 5.0 );\n* y = myquantile( 0.4 );\n* // returns ~0.210\n*\n* y = myquantile( 0.8 );\n* // returns ~0.639\n*\n* y = myquantile( 1.0 );\n* // returns 1.0\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
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EA4CvD,SAASC,EAAUC,EAAGC,EAAI,CACzB,OAAKL,EAAOK,CAAE,GAAKL,EAAOI,CAAE,GAAKC,GAAK,GAAOD,EAAI,GAAOA,EAAI,EACpD,IAEDH,EAAOG,EAAIF,EAAOG,CAAE,CAAE,EAAIA,CAClC,CAKAN,EAAO,QAAUI,IC9EjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EAsBvD,SAASC,EAASC,EAAI,CACrB,GAAKJ,EAAOI,CAAE,GAAKA,GAAK,EACvB,OAAOL,EAAkB,GAAI,EAE9B,OAAOM,EAaP,SAASA,EAAUC,EAAI,CACtB,OAAKN,EAAOM,CAAE,GAAKA,EAAI,GAAOA,EAAI,EAC1B,IAEDL,EAAOK,EAAIJ,EAAOE,CAAE,CAAE,EAAIA,CAClC,CACD,CAKAN,EAAO,QAAUK,IC5BjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "expm1", "log1p", "quantile", "p", "c", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "isnan", "expm1", "log1p", "factory", "c", "quantile", "p", "setReadOnly", "main", "factory"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="22.673ex" height="5.676ex" style="vertical-align: -1.838ex;" viewBox="0 -1652.5 9762.1 2443.8" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title">
|
|
2
|
+
<title id="MathJax-SVG-1-Title">upper Q left-parenthesis p semicolon c right-parenthesis equals StartFraction left-parenthesis 1 plus c right-parenthesis Superscript p Baseline minus 1 Over c EndFraction</title>
|
|
3
|
+
<defs aria-hidden="true">
|
|
4
|
+
<path stroke-width="1" id="E1-MJMATHI-51" d="M399 -80Q399 -47 400 -30T402 -11V-7L387 -11Q341 -22 303 -22Q208 -22 138 35T51 201Q50 209 50 244Q50 346 98 438T227 601Q351 704 476 704Q514 704 524 703Q621 689 680 617T740 435Q740 255 592 107Q529 47 461 16L444 8V3Q444 2 449 -24T470 -66T516 -82Q551 -82 583 -60T625 -3Q631 11 638 11Q647 11 649 2Q649 -6 639 -34T611 -100T557 -165T481 -194Q399 -194 399 -87V-80ZM636 468Q636 523 621 564T580 625T530 655T477 665Q429 665 379 640Q277 591 215 464T153 216Q153 110 207 59Q231 38 236 38V46Q236 86 269 120T347 155Q372 155 390 144T417 114T429 82T435 55L448 64Q512 108 557 185T619 334T636 468ZM314 18Q362 18 404 39L403 49Q399 104 366 115Q354 117 347 117Q344 117 341 117T337 118Q317 118 296 98T274 52Q274 18 314 18Z"></path>
|
|
5
|
+
<path stroke-width="1" id="E1-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"></path>
|
|
6
|
+
<path stroke-width="1" id="E1-MJMATHI-70" d="M23 287Q24 290 25 295T30 317T40 348T55 381T75 411T101 433T134 442Q209 442 230 378L240 387Q302 442 358 442Q423 442 460 395T497 281Q497 173 421 82T249 -10Q227 -10 210 -4Q199 1 187 11T168 28L161 36Q160 35 139 -51T118 -138Q118 -144 126 -145T163 -148H188Q194 -155 194 -157T191 -175Q188 -187 185 -190T172 -194Q170 -194 161 -194T127 -193T65 -192Q-5 -192 -24 -194H-32Q-39 -187 -39 -183Q-37 -156 -26 -148H-6Q28 -147 33 -136Q36 -130 94 103T155 350Q156 355 156 364Q156 405 131 405Q109 405 94 377T71 316T59 280Q57 278 43 278H29Q23 284 23 287ZM178 102Q200 26 252 26Q282 26 310 49T356 107Q374 141 392 215T411 325V331Q411 405 350 405Q339 405 328 402T306 393T286 380T269 365T254 350T243 336T235 326L232 322Q232 321 229 308T218 264T204 212Q178 106 178 102Z"></path>
|
|
7
|
+
<path stroke-width="1" id="E1-MJMAIN-3B" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 85 94 103T137 121Q202 121 202 8Q202 -44 183 -94T144 -169T118 -194Q115 -194 106 -186T95 -174Q94 -171 107 -155T137 -107T160 -38Q161 -32 162 -22T165 -4T165 4Q165 5 161 4T142 0Q110 0 94 18T78 60Z"></path>
|
|
8
|
+
<path stroke-width="1" id="E1-MJMATHI-63" d="M34 159Q34 268 120 355T306 442Q362 442 394 418T427 355Q427 326 408 306T360 285Q341 285 330 295T319 325T330 359T352 380T366 386H367Q367 388 361 392T340 400T306 404Q276 404 249 390Q228 381 206 359Q162 315 142 235T121 119Q121 73 147 50Q169 26 205 26H209Q321 26 394 111Q403 121 406 121Q410 121 419 112T429 98T420 83T391 55T346 25T282 0T202 -11Q127 -11 81 37T34 159Z"></path>
|
|
9
|
+
<path stroke-width="1" id="E1-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"></path>
|
|
10
|
+
<path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path>
|
|
11
|
+
<path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path>
|
|
12
|
+
<path stroke-width="1" id="E1-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"></path>
|
|
13
|
+
<path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path>
|
|
14
|
+
</defs>
|
|
15
|
+
<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
|
|
16
|
+
<use xlink:href="#E1-MJMATHI-51" x="0" y="0"></use>
|
|
17
|
+
<use xlink:href="#E1-MJMAIN-28" x="791" y="0"></use>
|
|
18
|
+
<use xlink:href="#E1-MJMATHI-70" x="1181" y="0"></use>
|
|
19
|
+
<use xlink:href="#E1-MJMAIN-3B" x="1684" y="0"></use>
|
|
20
|
+
<use xlink:href="#E1-MJMATHI-63" x="2129" y="0"></use>
|
|
21
|
+
<use xlink:href="#E1-MJMAIN-29" x="2563" y="0"></use>
|
|
22
|
+
<use xlink:href="#E1-MJMAIN-3D" x="3230" y="0"></use>
|
|
23
|
+
<g transform="translate(4008,0)">
|
|
24
|
+
<g transform="translate(397,0)">
|
|
25
|
+
<rect stroke="none" width="5235" height="60" x="0" y="220"></rect>
|
|
26
|
+
<g transform="translate(60,770)">
|
|
27
|
+
<use xlink:href="#E1-MJMAIN-28" x="0" y="0"></use>
|
|
28
|
+
<use xlink:href="#E1-MJMAIN-31" x="389" y="0"></use>
|
|
29
|
+
<use xlink:href="#E1-MJMAIN-2B" x="1112" y="0"></use>
|
|
30
|
+
<use xlink:href="#E1-MJMATHI-63" x="2112" y="0"></use>
|
|
31
|
+
<g transform="translate(2546,0)">
|
|
32
|
+
<use xlink:href="#E1-MJMAIN-29" x="0" y="0"></use>
|
|
33
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMATHI-70" x="550" y="513"></use>
|
|
34
|
+
</g>
|
|
35
|
+
<use xlink:href="#E1-MJMAIN-2212" x="3614" y="0"></use>
|
|
36
|
+
<use xlink:href="#E1-MJMAIN-31" x="4614" y="0"></use>
|
|
37
|
+
</g>
|
|
38
|
+
<use xlink:href="#E1-MJMATHI-63" x="2400" y="-686"></use>
|
|
39
|
+
</g>
|
|
40
|
+
</g>
|
|
41
|
+
</g>
|
|
42
|
+
</svg>
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Evaluates the quantile function for a Bradford distribution.
|
|
23
|
+
*
|
|
24
|
+
* ## Notes
|
|
25
|
+
*
|
|
26
|
+
* - If `c <= 0`, the function returns `NaN`.
|
|
27
|
+
*
|
|
28
|
+
* @param c - shape parameter
|
|
29
|
+
* @returns evaluated quantile function
|
|
30
|
+
*/
|
|
31
|
+
type Unary = ( c: number ) => number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Interface for the quantile function of a Bradford distribution.
|
|
35
|
+
*/
|
|
36
|
+
interface Quantile {
|
|
37
|
+
/**
|
|
38
|
+
* Evaluates the quantile function for a Bradford distribution with shape parameter `c` at a probability `p`.
|
|
39
|
+
*
|
|
40
|
+
* ## Notes
|
|
41
|
+
*
|
|
42
|
+
* - If `p < 0` or `p > 1`, the function returns `NaN`.
|
|
43
|
+
* - If `c <= 0`, the function returns `NaN`.
|
|
44
|
+
*
|
|
45
|
+
* @param p - input value
|
|
46
|
+
* @param c - shape parameter
|
|
47
|
+
* @returns evaluated quantile function
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = quantile( 0.1, 0.1 );
|
|
51
|
+
* // returns ~0.096
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = quantile( 0.5, 5.0 );
|
|
55
|
+
* // returns ~0.290
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = quantile( 1.0, 10.0 );
|
|
59
|
+
* // returns 1.0
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = quantile( 0.5, 0.0 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* var y = quantile( 2.0, 0.5 );
|
|
67
|
+
* // returns NaN
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* var y = quantile( -1.0, 0.5 );
|
|
71
|
+
* // returns NaN
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* var y = quantile( NaN, 1.0 );
|
|
75
|
+
* // returns NaN
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* var y = quantile( 1.0, NaN );
|
|
79
|
+
* // returns NaN
|
|
80
|
+
*/
|
|
81
|
+
( p: number, c: number ): number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns a function for evaluating the quantile function for a Bradford distribution with shape parameter `c`.
|
|
85
|
+
*
|
|
86
|
+
* @param c - shape parameter
|
|
87
|
+
* @returns quantile function
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* var myquantile = quantile.factory( 5.0 );
|
|
91
|
+
* var y = myquantile( 0.4 );
|
|
92
|
+
* // returns ~0.210
|
|
93
|
+
*
|
|
94
|
+
* y = myquantile( 0.8 );
|
|
95
|
+
* // returns ~0.639
|
|
96
|
+
*
|
|
97
|
+
* y = myquantile( 1.0 );
|
|
98
|
+
* // returns 1.0
|
|
99
|
+
*/
|
|
100
|
+
factory( c: number ): Unary;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Bradford distribution quantile function.
|
|
105
|
+
*
|
|
106
|
+
* @param p - input value
|
|
107
|
+
* @param c - shape parameter
|
|
108
|
+
* @returns evaluated quantile function
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* var y = quantile( 0.1, 0.1 );
|
|
112
|
+
* // returns ~0.096
|
|
113
|
+
*
|
|
114
|
+
* y = quantile( 0.5, 5.0 );
|
|
115
|
+
* // returns ~0.290
|
|
116
|
+
*
|
|
117
|
+
* var myquantile = quantile.factory( 5.0 );
|
|
118
|
+
* y = myquantile( 0.4 );
|
|
119
|
+
* // returns ~0.210
|
|
120
|
+
*
|
|
121
|
+
* y = myquantile( 0.8 );
|
|
122
|
+
* // returns ~0.639
|
|
123
|
+
*
|
|
124
|
+
* y = myquantile( 1.0 );
|
|
125
|
+
* // returns 1.0
|
|
126
|
+
*/
|
|
127
|
+
declare var quantile: Quantile;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
// EXPORTS //
|
|
131
|
+
|
|
132
|
+
export = quantile;
|
|
@@ -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_BRADFORD_QUANTILE_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_BRADFORD_QUANTILE_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 quantile function for a Bradford distribution.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_bradford_quantile( const double p, const double c );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_BRADFORD_QUANTILE_H
|
package/lib/factory.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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 constantFunction = require( '@stdlib/utils-constant-function' );
|
|
24
|
+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
25
|
+
var expm1 = require( '@stdlib/math-base-special-expm1' );
|
|
26
|
+
var log1p = require( '@stdlib/math-base-special-log1p' );
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// MAIN //
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns a function for evaluating the quantile function for a Bradford distribution with shape parameter `c`.
|
|
33
|
+
*
|
|
34
|
+
* @param {PositiveNumber} c - shape parameter
|
|
35
|
+
* @returns {NonNegativeNumber} quantile function
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var quantile = factory( 5.0 );
|
|
39
|
+
* var y = quantile( 0.4 );
|
|
40
|
+
* // returns ~0.210
|
|
41
|
+
*
|
|
42
|
+
* y = quantile( 0.8 );
|
|
43
|
+
* // returns ~0.639
|
|
44
|
+
*
|
|
45
|
+
* y = quantile( 1.0 );
|
|
46
|
+
* // returns 1.0
|
|
47
|
+
*/
|
|
48
|
+
function factory( c ) {
|
|
49
|
+
if ( isnan( c ) || c <= 0.0 ) {
|
|
50
|
+
return constantFunction( NaN );
|
|
51
|
+
}
|
|
52
|
+
return quantile;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Evaluates the quantile function for a Bradford distribution.
|
|
56
|
+
*
|
|
57
|
+
* @private
|
|
58
|
+
* @param {Probability} p - input value
|
|
59
|
+
* @returns {number} evaluated quantile function
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = quantile( 0.3 );
|
|
63
|
+
* // returns <number>
|
|
64
|
+
*/
|
|
65
|
+
function quantile( p ) {
|
|
66
|
+
if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
|
|
67
|
+
return NaN;
|
|
68
|
+
}
|
|
69
|
+
return expm1( p * log1p( c ) ) / c;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// EXPORTS //
|
|
75
|
+
|
|
76
|
+
module.exports = factory;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
/**
|
|
22
|
+
* Bradford distribution quantile function.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/stats-base-dists-bradford-quantile
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var quantile = require( '@stdlib/stats-base-dists-bradford-quantile' );
|
|
28
|
+
*
|
|
29
|
+
* var y = quantile( 0.1, 0.1 );
|
|
30
|
+
* // returns ~0.096
|
|
31
|
+
*
|
|
32
|
+
* var y = quantile( 0.5, 5.0 );
|
|
33
|
+
* // returns ~0.290
|
|
34
|
+
*
|
|
35
|
+
* var myquantile = quantile.factory( 5.0 );
|
|
36
|
+
* y = myquantile( 0.4 );
|
|
37
|
+
* // returns ~0.210
|
|
38
|
+
*
|
|
39
|
+
* y = myquantile( 0.8 );
|
|
40
|
+
* // returns ~0.639
|
|
41
|
+
*
|
|
42
|
+
* y = myquantile( 1.0 );
|
|
43
|
+
* // returns 1.0
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// MODULES //
|
|
47
|
+
|
|
48
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
49
|
+
var main = require( './main.js' );
|
|
50
|
+
var factory = require( './factory.js' );
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// MAIN //
|
|
54
|
+
|
|
55
|
+
setReadOnly( main, 'factory', factory );
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// EXPORTS //
|
|
59
|
+
|
|
60
|
+
module.exports = main;
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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 isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
24
|
+
var expm1 = require( '@stdlib/math-base-special-expm1' );
|
|
25
|
+
var log1p = require( '@stdlib/math-base-special-log1p' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Evaluates the quantile function for a Bradford distribution with shape parameter `c` at a probability `p`.
|
|
32
|
+
*
|
|
33
|
+
* @param {Probability} p - input value
|
|
34
|
+
* @param {PositiveNumber} c - shape parameter
|
|
35
|
+
* @returns {NonNegativeNumber} evaluated quantile function
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = quantile( 0.1, 0.1 );
|
|
39
|
+
* // returns ~0.096
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = quantile( 0.5, 5.0 );
|
|
43
|
+
* // returns ~0.290
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = quantile( 1.0, 10.0 );
|
|
47
|
+
* // returns 1.0
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = quantile( 0.5, 0.0 );
|
|
51
|
+
* // returns NaN
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = quantile( 2.0, 0.5 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = quantile( -1.0, 0.5 );
|
|
59
|
+
* // returns NaN
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = quantile( NaN, 1.0 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* var y = quantile( 1.0, NaN );
|
|
67
|
+
* // returns NaN
|
|
68
|
+
*/
|
|
69
|
+
function quantile( p, c ) {
|
|
70
|
+
if ( isnan( c ) || isnan( p ) || c <= 0.0 || p < 0.0 || p > 1.0 ) {
|
|
71
|
+
return NaN;
|
|
72
|
+
}
|
|
73
|
+
return expm1( p * log1p( c ) ) / c;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
// EXPORTS //
|
|
78
|
+
|
|
79
|
+
module.exports = quantile;
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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 quantile function for a Bradford distribution with shape parameter `c` at a probability `p`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {Probability} p - input value
|
|
33
|
+
* @param {PositiveNumber} c - shape parameter
|
|
34
|
+
* @returns {NonNegativeNumber} evaluated quantile function
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var y = quantile( 0.1, 0.1 );
|
|
38
|
+
* // returns ~0.096
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var y = quantile( 0.5, 5.0 );
|
|
42
|
+
* // returns ~0.290
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var y = quantile( 1.0, 10.0 );
|
|
46
|
+
* // returns 1.0
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var y = quantile( 0.5, 0.0 );
|
|
50
|
+
* // returns NaN
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var y = quantile( 2.0, 0.5 );
|
|
54
|
+
* // returns NaN
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* var y = quantile( -1.0, 0.5 );
|
|
58
|
+
* // returns NaN
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* var y = quantile( NaN, 1.0 );
|
|
62
|
+
* // returns NaN
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* var y = quantile( 1.0, NaN );
|
|
66
|
+
* // returns NaN
|
|
67
|
+
*/
|
|
68
|
+
function quantile( p, c ) {
|
|
69
|
+
return addon( p, c );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// EXPORTS //
|
|
74
|
+
|
|
75
|
+
module.exports = quantile;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
"@stdlib/math-base-special-expm1",
|
|
44
|
+
"@stdlib/math-base-special-log1p"
|
|
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/constants-float64-eps",
|
|
60
|
+
"@stdlib/math-base-assert-is-nan",
|
|
61
|
+
"@stdlib/math-base-special-expm1",
|
|
62
|
+
"@stdlib/math-base-special-log1p"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"task": "examples",
|
|
67
|
+
"wasm": false,
|
|
68
|
+
"src": [
|
|
69
|
+
"./src/main.c"
|
|
70
|
+
],
|
|
71
|
+
"include": [
|
|
72
|
+
"./include"
|
|
73
|
+
],
|
|
74
|
+
"libraries": [],
|
|
75
|
+
"libpath": [],
|
|
76
|
+
"dependencies": [
|
|
77
|
+
"@stdlib/math-base-assert-is-nan",
|
|
78
|
+
"@stdlib/math-base-special-expm1",
|
|
79
|
+
"@stdlib/math-base-special-log1p"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/stats-base-dists-bradford-quantile",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bradford distribution quantile function.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
18
|
+
"directories": {
|
|
19
|
+
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
21
|
+
"lib": "./lib",
|
|
22
|
+
"src": "./src",
|
|
23
|
+
"dist": "./dist"
|
|
24
|
+
},
|
|
25
|
+
"types": "./docs/types",
|
|
26
|
+
"scripts": {},
|
|
27
|
+
"homepage": "https://stdlib.io",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git://github.com/stdlib-js/stats-base-dists-bradford-quantile.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
37
|
+
"@stdlib/math-base-napi-binary": "^0.3.1",
|
|
38
|
+
"@stdlib/math-base-special-expm1": "^0.2.3",
|
|
39
|
+
"@stdlib/math-base-special-log1p": "^0.2.3",
|
|
40
|
+
"@stdlib/utils-constant-function": "^0.2.2",
|
|
41
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
42
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=0.10.0",
|
|
47
|
+
"npm": ">2.7.0"
|
|
48
|
+
},
|
|
49
|
+
"os": [
|
|
50
|
+
"aix",
|
|
51
|
+
"darwin",
|
|
52
|
+
"freebsd",
|
|
53
|
+
"linux",
|
|
54
|
+
"macos",
|
|
55
|
+
"openbsd",
|
|
56
|
+
"sunos",
|
|
57
|
+
"win32",
|
|
58
|
+
"windows"
|
|
59
|
+
],
|
|
60
|
+
"keywords": [
|
|
61
|
+
"stdlib",
|
|
62
|
+
"stdmath",
|
|
63
|
+
"statistics",
|
|
64
|
+
"stats",
|
|
65
|
+
"distribution",
|
|
66
|
+
"dist",
|
|
67
|
+
"probability",
|
|
68
|
+
"cdf",
|
|
69
|
+
"inverse",
|
|
70
|
+
"continuous",
|
|
71
|
+
"quantile",
|
|
72
|
+
"percentile",
|
|
73
|
+
"bradford"
|
|
74
|
+
],
|
|
75
|
+
"funding": {
|
|
76
|
+
"type": "opencollective",
|
|
77
|
+
"url": "https://opencollective.com/stdlib"
|
|
78
|
+
}
|
|
79
|
+
}
|
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/bradford/quantile.h"
|
|
20
|
+
#include "stdlib/math/base/napi/binary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_bradford_quantile )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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/bradford/quantile.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/math/base/special/expm1.h"
|
|
22
|
+
#include "stdlib/math/base/special/log1p.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates the quantile function for a Bradford distribution with shape parameter `c` at a probability `p`.
|
|
26
|
+
*
|
|
27
|
+
* @param p input probability
|
|
28
|
+
* @param c shape parameter
|
|
29
|
+
* @return evaluated quantile function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* double y = stdlib_base_dists_bradford_quantile( 0.5, 5.0 );
|
|
33
|
+
* // returns ~0.290
|
|
34
|
+
*/
|
|
35
|
+
double stdlib_base_dists_bradford_quantile( const double p, const double c ) {
|
|
36
|
+
if (
|
|
37
|
+
stdlib_base_is_nan( p ) ||
|
|
38
|
+
stdlib_base_is_nan( c ) ||
|
|
39
|
+
c <= 0.0 ||
|
|
40
|
+
p < 0.0 ||
|
|
41
|
+
p > 1.0
|
|
42
|
+
) {
|
|
43
|
+
return 0.0/0.0; // NaN
|
|
44
|
+
}
|
|
45
|
+
return stdlib_base_expm1( p * stdlib_base_log1p( c ) ) / c;
|
|
46
|
+
}
|