@ohos-ports/stdlib-stats-base-dists-gamma-quantile 0.0.0-stage → 0.2.3-beta.1

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 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 CHANGED
@@ -1,3 +1,264 @@
1
- # Temporary Holding Version
1
+ <!--
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 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
+ > [Gamma][gamma-distribution] distribution [quantile function][quantile-function].
37
+
38
+ <section class="intro">
39
+
40
+ The [quantile function][quantile-function] for a [gamma][gamma-distribution] random variable is
41
+
42
+ <!-- <equation class="equation" label="eq:gamma_quantile_function" align="center" raw="Q(p;\alpha,\beta) = \frac{1}{\beta} P^{-1}\left( p, \alpha \right )" data-equation="eq:quantile_function" alt="Quantile function for a Gamma distribution."> -->
43
+
44
+ <div class="equation" align="center" data-raw-text="Q(p;\alpha,\beta) = \frac{1}{\beta} P^{-1}\left( p, \alpha \right )" data-equation="eq:gamma_quantile_function">
45
+ <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/stats/base/dists/gamma/quantile/docs/img/equation_gamma_quantile_function.svg" alt="Quantile function for a Gamma distribution.">
46
+ <br>
47
+ </div>
48
+
49
+ <!-- </equation> -->
50
+
51
+ for `0 <= p < 1`, where `alpha` is the shape parameter and `beta` is the rate parameter of the distribution. `P^{-1}` is the inverse of the lower regularized incomplete gamma function.
52
+
53
+ </section>
54
+
55
+ <!-- /.intro -->
56
+
57
+ <section class="installation">
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ npm install @stdlib/stats-base-dists-gamma-quantile
63
+ ```
64
+
65
+ </section>
66
+
67
+ <section class="usage">
68
+
69
+ ## Usage
70
+
71
+ ```javascript
72
+ var quantile = require( '@stdlib/stats-base-dists-gamma-quantile' );
73
+ ```
74
+
75
+ #### quantile( p, alpha, beta )
76
+
77
+ Evaluates the [quantile function][quantile-function] for a [gamma][gamma-distribution] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).
78
+
79
+ ```javascript
80
+ var y = quantile( 0.8, 2.0, 1.0 );
81
+ // returns ~2.994
82
+
83
+ y = quantile( 0.5, 4.0, 2.0 );
84
+ // returns ~1.836
85
+ ```
86
+
87
+ If provided a probability `p` outside the interval `[0,1]`, the function returns `NaN`.
88
+
89
+ ```javascript
90
+ var y = quantile( 1.9, 1.0, 1.0 );
91
+ // returns NaN
92
+
93
+ y = quantile( -0.1, 1.0, 1.0 );
94
+ // returns NaN
95
+ ```
96
+
97
+ If provided `NaN` as any argument, the function returns `NaN`.
98
+
99
+ ```javascript
100
+ var y = quantile( NaN, 1.0, 1.0 );
101
+ // returns NaN
102
+
103
+ y = quantile( 0.0, NaN, 1.0 );
104
+ // returns NaN
105
+
106
+ y = quantile( 0.0, 1.0, NaN );
107
+ // returns NaN
108
+ ```
109
+
110
+ If provided `alpha < 0`, the function returns `NaN`.
111
+
112
+ ```javascript
113
+ var y = quantile( 0.4, -1.0, 1.0 );
114
+ // returns NaN
115
+ ```
116
+
117
+ If provided `alpha = 0`, the function evaluates the [quantile function][quantile-function] of a [degenerate distribution][degenerate-distribution] centered at `0`.
118
+
119
+ ```javascript
120
+ var y = quantile( 0.3, 0.0, 2.0 );
121
+ // returns 0.0
122
+
123
+ y = quantile( 0.9, 0.0, 2.0 );
124
+ // returns 0.0
125
+ ```
126
+
127
+ If provided `beta <= 0`, the function returns `NaN`.
128
+
129
+ ```javascript
130
+ var y = quantile( 0.4, 1.0, -1.0 );
131
+ // returns NaN
132
+ ```
133
+
134
+ #### quantile.factory( alpha, beta )
135
+
136
+ Returns a function for evaluating the [quantile function][quantile-function] of a [gamma][gamma-distribution] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).
137
+
138
+ ```javascript
139
+ var myquantile = quantile.factory( 2.0, 2.0 );
140
+ var y = myquantile( 0.8 );
141
+ // returns ~1.497
142
+
143
+ y = myquantile( 0.4 );
144
+ // returns ~0.688
145
+ ```
146
+
147
+ </section>
148
+
149
+ <!-- /.usage -->
150
+
151
+ <section class="examples">
152
+
153
+ ## Examples
154
+
155
+ <!-- eslint no-undef: "error" -->
156
+
157
+ ```javascript
158
+ var uniform = require( '@stdlib/random-array-uniform' );
159
+ var logEachMap = require( '@stdlib/console-log-each-map' );
160
+ var quantile = require( '@stdlib/stats-base-dists-gamma-quantile' );
161
+
162
+ var opts = {
163
+ 'dtype': 'float64'
164
+ };
165
+ var p = uniform( 20, 0.0, 1.0, opts );
166
+ var alpha = uniform( 20, 0.0, 5.0, opts );
167
+ var beta = uniform( 20, 0.0, 5.0, opts );
168
+
169
+ logEachMap( 'p: %0.4f, α: %0.4f, β: %0.4f, Q(p;α,β): %0.4f', p, alpha, beta, quantile );
170
+ ```
171
+
172
+ </section>
173
+
174
+ <!-- /.examples -->
175
+
176
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
177
+
178
+ <section class="related">
179
+
180
+ </section>
181
+
182
+ <!-- /.related -->
183
+
184
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
185
+
186
+
187
+ <section class="main-repo" >
188
+
189
+ * * *
190
+
191
+ ## Notice
192
+
193
+ 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.
194
+
195
+ 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].
196
+
197
+ #### Community
198
+
199
+ [![Chat][chat-image]][chat-url]
200
+
201
+ ---
202
+
203
+ ## License
204
+
205
+ See [LICENSE][stdlib-license].
206
+
207
+
208
+ ## Copyright
209
+
210
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
211
+
212
+ </section>
213
+
214
+ <!-- /.stdlib -->
215
+
216
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
217
+
218
+ <section class="links">
219
+
220
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-gamma-quantile.svg
221
+ [npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-gamma-quantile
222
+
223
+ [test-image]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/actions/workflows/test.yml/badge.svg?branch=v0.2.3
224
+ [test-url]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/actions/workflows/test.yml?query=branch:v0.2.3
225
+
226
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-gamma-quantile/main.svg
227
+ [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-gamma-quantile?branch=main
228
+
229
+ <!--
230
+
231
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/stats-base-dists-gamma-quantile.svg
232
+ [dependencies-url]: https://david-dm.org/stdlib-js/stats-base-dists-gamma-quantile/main
233
+
234
+ -->
235
+
236
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
237
+ [chat-url]: https://stdlib.zulipchat.com
238
+
239
+ [stdlib]: https://github.com/stdlib-js/stdlib
240
+
241
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
242
+
243
+ [umd]: https://github.com/umdjs/umd
244
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
245
+
246
+ [deno-url]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/tree/deno
247
+ [deno-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/blob/deno/README.md
248
+ [umd-url]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/tree/umd
249
+ [umd-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/blob/umd/README.md
250
+ [esm-url]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/tree/esm
251
+ [esm-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/blob/esm/README.md
252
+ [branches-url]: https://github.com/stdlib-js/stats-base-dists-gamma-quantile/blob/main/branches.md
253
+
254
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-base-dists-gamma-quantile/main/LICENSE
255
+
256
+ [degenerate-distribution]: https://en.wikipedia.org/wiki/Degenerate_distribution
257
+
258
+ [gamma-distribution]: https://en.wikipedia.org/wiki/Gamma_distribution
259
+
260
+ [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
261
+
262
+ </section>
263
+
264
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import quantile from '../docs/types/index';
3
+ export = quantile;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var c=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var a=c(function(R,s){
2
+ var t=require('@ohos-ports/stdlib-math-base-assert-is-nan/dist'),v=require('@stdlib/math-base-special-gammaincinv/dist');function N(e,r,n){return t(r)||t(n)||t(e)||r<0||n<=0||e<0||e>1?NaN:r===0?0:1/n*v(e,r)}s.exports=N
3
+ });var o=c(function(j,f){
4
+ var m=require('@stdlib/utils-constant-function/dist'),y=require('@stdlib/math-base-special-gammaincinv/dist'),g=require('@stdlib/stats-base-dists-degenerate-quantile/dist').factory,u=require('@ohos-ports/stdlib-math-base-assert-is-nan/dist');function x(e,r){if(u(e)||u(r)||e<0||r<=0)return m(NaN);if(e===0)return g(0);return n;function n(i){return u(i)||i<0||i>1?NaN:1/r*y(i,e)}}f.exports=x
5
+ });var d=require('@ohos-ports/stdlib-utils-define-nonenumerable-read-only-property/dist'),q=a(),F=o();d(q,"factory",F);module.exports=q;
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) 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( '@ohos-ports/stdlib-math-base-assert-is-nan' );\nvar gammaincinv = require( '@stdlib/math-base-special-gammaincinv' );\n\n\n// MAIN //\n\n/**\n* Evaluates the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta` at a probability `p`.\n*\n* @param {Probability} p - input value\n* @param {NonNegativeNumber} alpha - shape parameter\n* @param {PositiveNumber} beta - rate parameter\n* @returns {number} evaluated quantile function\n*\n* @example\n* var y = quantile( 0.8, 2.0, 1.0 );\n* // returns ~2.994\n*\n* @example\n* var y = quantile( 0.5, 4.0, 2.0 );\n* // returns ~1.836\n*\n* @example\n* var y = quantile( 1.1, 1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( -0.2, 1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( NaN, 1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.0, 1.0, NaN );\n* // returns NaN\n*\n* @example\n* // Non-positive shape parameter:\n* var y = quantile( 0.5, -1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* // Non-positive rate parameter:\n* var y = quantile( 0.5, 1.0, -1.0 );\n* // returns NaN\n*/\nfunction quantile( p, alpha, beta ) {\n\tif (\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\n\t\tisnan( p ) ||\n\t\talpha < 0.0 ||\n\t\tbeta <= 0.0 ||\n\t\tp < 0.0 ||\n\t\tp > 1.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( alpha === 0.0 ) {\n\t\treturn 0.0;\n\t}\n\treturn ( 1.0 / beta ) * gammaincinv( p, alpha );\n}\n\n\n// EXPORTS //\n\nmodule.exports = quantile;\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// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar gammaincinv = require( '@stdlib/math-base-special-gammaincinv' );\nvar degenerate = require( '@stdlib/stats-base-dists-degenerate-quantile' ).factory;\nvar isnan = require( '@ohos-ports/stdlib-math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta`.\n*\n* @param {NonNegativeNumber} alpha - shape parameter\n* @param {PositiveNumber} beta - rate parameter\n* @returns {Function} quantile function\n*\n* @example\n* var quantile = factory( 2.5, 0.5 );\n* var y = quantile( 0.5 );\n* // returns ~4.351\n*\n* y = quantile( 0.8 );\n* // returns ~7.289\n*/\nfunction factory( alpha, beta ) {\n\tif (\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\n\t\talpha < 0.0 ||\n\t\tbeta <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\tif ( alpha === 0.0 ) {\n\t\treturn degenerate( 0.0 );\n\t}\n\treturn quantile;\n\n\t/**\n\t* Evaluates the quantile function for a gamma 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 ( 1.0 / beta ) * gammaincinv( p, alpha );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\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* Gamma distribution quantile function.\n*\n* @module @stdlib/stats-base-dists-gamma-quantile\n*\n* @example\n* var quantile = require( '@stdlib/stats-base-dists-gamma-quantile' );\n*\n* var y = quantile( 0.8, 1.0, 1.0 );\n* // returns ~1.609\n*\n* var myquantile = quantile.factory( 2.0, 2.0 );\n* y = myquantile( 0.8 );\n* // returns ~1.497\n*\n* y = myquantile( 0.4 );\n* // returns ~0.688\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@ohos-ports/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,EAAc,QAAS,uCAAwC,EAmDnE,SAASC,EAAUC,EAAGC,EAAOC,EAAO,CACnC,OACCL,EAAOI,CAAM,GACbJ,EAAOK,CAAK,GACZL,EAAOG,CAAE,GACTC,EAAQ,GACRC,GAAQ,GACRF,EAAI,GACJA,EAAI,EAEG,IAEHC,IAAU,EACP,EAEC,EAAMC,EAASJ,EAAaE,EAAGC,CAAM,CAC/C,CAKAL,EAAO,QAAUG,IC/FjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAc,QAAS,uCAAwC,EAC/DC,EAAa,QAAS,8CAA+C,EAAE,QACvEC,EAAQ,QAAS,iCAAkC,EAoBvD,SAASC,EAASC,EAAOC,EAAO,CAC/B,GACCH,EAAOE,CAAM,GACbF,EAAOG,CAAK,GACZD,EAAQ,GACRC,GAAQ,EAER,OAAON,EAAkB,GAAI,EAE9B,GAAKK,IAAU,EACd,OAAOH,EAAY,CAAI,EAExB,OAAOK,EAaP,SAASA,EAAUC,EAAI,CACtB,OAAKL,EAAOK,CAAE,GAAKA,EAAI,GAAOA,EAAI,EAC1B,IAEC,EAAMF,EAASL,EAAaO,EAAGH,CAAM,CAC/C,CACD,CAKAN,EAAO,QAAUK,ICxCjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "gammaincinv", "quantile", "p", "alpha", "beta", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "gammaincinv", "degenerate", "isnan", "factory", "alpha", "beta", "quantile", "p", "setReadOnly", "main", "factory"]
7
+ }
@@ -0,0 +1,49 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="25.013ex" height="5.676ex" style="vertical-align: -2.338ex;" viewBox="0 -1437.2 10769.4 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 alpha comma beta right-parenthesis equals StartFraction 1 Over beta EndFraction upper P Superscript negative 1 Baseline left-parenthesis p comma alpha right-parenthesis</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-3B1" d="M34 156Q34 270 120 356T309 442Q379 442 421 402T478 304Q484 275 485 237V208Q534 282 560 374Q564 388 566 390T582 393Q603 393 603 385Q603 376 594 346T558 261T497 161L486 147L487 123Q489 67 495 47T514 26Q528 28 540 37T557 60Q559 67 562 68T577 70Q597 70 597 62Q597 56 591 43Q579 19 556 5T512 -10H505Q438 -10 414 62L411 69L400 61Q390 53 370 41T325 18T267 -2T203 -11Q124 -11 79 39T34 156ZM208 26Q257 26 306 47T379 90L403 112Q401 255 396 290Q382 405 304 405Q235 405 183 332Q156 292 139 224T121 120Q121 71 146 49T208 26Z"></path>
9
+ <path stroke-width="1" id="E1-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"></path>
10
+ <path stroke-width="1" id="E1-MJMATHI-3B2" d="M29 -194Q23 -188 23 -186Q23 -183 102 134T186 465Q208 533 243 584T309 658Q365 705 429 705H431Q493 705 533 667T573 570Q573 465 469 396L482 383Q533 332 533 252Q533 139 448 65T257 -10Q227 -10 203 -2T165 17T143 40T131 59T126 65L62 -188Q60 -194 42 -194H29ZM353 431Q392 431 427 419L432 422Q436 426 439 429T449 439T461 453T472 471T484 495T493 524T501 560Q503 569 503 593Q503 611 502 616Q487 667 426 667Q384 667 347 643T286 582T247 514T224 455Q219 439 186 308T152 168Q151 163 151 147Q151 99 173 68Q204 26 260 26Q302 26 349 51T425 137Q441 171 449 214T457 279Q457 337 422 372Q380 358 347 358H337Q258 358 258 389Q258 396 261 403Q275 431 353 431Z"></path>
11
+ <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>
12
+ <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>
13
+ <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>
14
+ <path stroke-width="1" id="E1-MJMATHI-50" d="M287 628Q287 635 230 637Q206 637 199 638T192 648Q192 649 194 659Q200 679 203 681T397 683Q587 682 600 680Q664 669 707 631T751 530Q751 453 685 389Q616 321 507 303Q500 302 402 301H307L277 182Q247 66 247 59Q247 55 248 54T255 50T272 48T305 46H336Q342 37 342 35Q342 19 335 5Q330 0 319 0Q316 0 282 1T182 2Q120 2 87 2T51 1Q33 1 33 11Q33 13 36 25Q40 41 44 43T67 46Q94 46 127 49Q141 52 146 61Q149 65 218 339T287 628ZM645 554Q645 567 643 575T634 597T609 619T560 635Q553 636 480 637Q463 637 445 637T416 636T404 636Q391 635 386 627Q384 621 367 550T332 412T314 344Q314 342 395 342H407H430Q542 342 590 392Q617 419 631 471T645 554Z"></path>
15
+ <path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path>
16
+ </defs>
17
+ <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
18
+ <use xlink:href="#E1-MJMATHI-51" x="0" y="0"></use>
19
+ <use xlink:href="#E1-MJMAIN-28" x="791" y="0"></use>
20
+ <use xlink:href="#E1-MJMATHI-70" x="1181" y="0"></use>
21
+ <use xlink:href="#E1-MJMAIN-3B" x="1684" y="0"></use>
22
+ <use xlink:href="#E1-MJMATHI-3B1" x="2129" y="0"></use>
23
+ <use xlink:href="#E1-MJMAIN-2C" x="2770" y="0"></use>
24
+ <use xlink:href="#E1-MJMATHI-3B2" x="3215" y="0"></use>
25
+ <use xlink:href="#E1-MJMAIN-29" x="3788" y="0"></use>
26
+ <use xlink:href="#E1-MJMAIN-3D" x="4456" y="0"></use>
27
+ <g transform="translate(5234,0)">
28
+ <g transform="translate(397,0)">
29
+ <rect stroke="none" width="693" height="60" x="0" y="220"></rect>
30
+ <use xlink:href="#E1-MJMAIN-31" x="96" y="676"></use>
31
+ <use xlink:href="#E1-MJMATHI-3B2" x="60" y="-726"></use>
32
+ </g>
33
+ </g>
34
+ <g transform="translate(6445,0)">
35
+ <use xlink:href="#E1-MJMATHI-50" x="0" y="0"></use>
36
+ <g transform="translate(784,412)">
37
+ <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-2212" x="0" y="0"></use>
38
+ <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-31" x="778" y="0"></use>
39
+ </g>
40
+ </g>
41
+ <g transform="translate(8401,0)">
42
+ <use xlink:href="#E1-MJMAIN-28" x="0" y="0"></use>
43
+ <use xlink:href="#E1-MJMATHI-70" x="389" y="0"></use>
44
+ <use xlink:href="#E1-MJMAIN-2C" x="893" y="0"></use>
45
+ <use xlink:href="#E1-MJMATHI-3B1" x="1338" y="0"></use>
46
+ <use xlink:href="#E1-MJMAIN-29" x="1978" y="0"></use>
47
+ </g>
48
+ </g>
49
+ </svg>
@@ -0,0 +1,132 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2019 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 gamma distribution.
23
+ *
24
+ * ## Notes
25
+ *
26
+ * - If `p < 0` or `p > 1`, the function returns `NaN`.
27
+ *
28
+ * @param p - input value
29
+ * @returns evaluated quantile function
30
+ */
31
+ type Unary = ( p: number ) => number;
32
+
33
+ /**
34
+ * Interface for the quantile function of a gamma distribution.
35
+ */
36
+ interface Quantile {
37
+ /**
38
+ * Evaluates the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta` at a probability `p`.
39
+ *
40
+ * ## Notes
41
+ *
42
+ * - If `p < 0` or `p > 1`, the function returns `NaN`.
43
+ * - If `alpha < 0` or `beta <= 0`, the function returns `NaN`.
44
+ *
45
+ * @param p - input value
46
+ * @param alpha - shape parameter
47
+ * @param beta - rate parameter
48
+ * @returns evaluated quantile function
49
+ *
50
+ * @example
51
+ * var y = quantile( 0.8, 2.0, 1.0 );
52
+ * // returns ~2.994
53
+ *
54
+ * @example
55
+ * var y = quantile( 0.5, 4.0, 2.0 );
56
+ * // returns ~1.836
57
+ *
58
+ * @example
59
+ * var y = quantile( 1.1, 1.0, 1.0 );
60
+ * // returns NaN
61
+ *
62
+ * @example
63
+ * var y = quantile( -0.2, 1.0, 1.0 );
64
+ * // returns NaN
65
+ *
66
+ * @example
67
+ * var y = quantile( NaN, 1.0, 1.0 );
68
+ * // returns NaN
69
+ *
70
+ * @example
71
+ * var y = quantile( 0.0, NaN, 1.0 );
72
+ * // returns NaN
73
+ *
74
+ * @example
75
+ * var y = quantile( 0.0, 1.0, NaN );
76
+ * // returns NaN
77
+ *
78
+ * @example
79
+ * // Non-positive shape parameter:
80
+ * var y = quantile( 0.5, -1.0, 1.0 );
81
+ * // returns NaN
82
+ *
83
+ * @example
84
+ * // Non-positive rate parameter:
85
+ * var y = quantile( 0.5, 1.0, -1.0 );
86
+ * // returns NaN
87
+ */
88
+ ( p: number, alpha: number, beta: number ): number;
89
+
90
+ /**
91
+ * Returns a function for evaluating the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta`.
92
+ *
93
+ * @param alpha - shape parameter
94
+ * @param beta - rate parameter
95
+ * @returns quantile function
96
+ *
97
+ * @example
98
+ * var myQuantile = quantile.factory( 2.5, 0.5 );
99
+ * var y = myQuantile( 0.5 );
100
+ * // returns ~4.351
101
+ *
102
+ * y = myQuantile( 0.8 );
103
+ * // returns ~7.289
104
+ */
105
+ factory( alpha: number, beta: number ): Unary;
106
+ }
107
+
108
+ /**
109
+ * Gamma distribution quantile function.
110
+ *
111
+ * @param p - input value
112
+ * @param alpha - shape parameter
113
+ * @param beta - rate parameter
114
+ * @returns evaluated quantile function
115
+ *
116
+ * @example
117
+ * var y = quantile( 0.8, 1.0, 1.0 );
118
+ * // returns ~1.609
119
+ *
120
+ * var myQuantile = quantile.factory( 2.0, 2.0 );
121
+ * y = myQuantile( 0.8 );
122
+ * // returns ~1.497
123
+ *
124
+ * y = myQuantile( 0.4 );
125
+ * // returns ~0.688
126
+ */
127
+ declare var quantile: Quantile;
128
+
129
+
130
+ // EXPORTS //
131
+
132
+ export = quantile;
package/lib/factory.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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 gammaincinv = require( '@stdlib/math-base-special-gammaincinv' );
25
+ var degenerate = require( '@stdlib/stats-base-dists-degenerate-quantile' ).factory;
26
+ var isnan = require( '@ohos-ports/stdlib-math-base-assert-is-nan' );
27
+
28
+
29
+ // MAIN //
30
+
31
+ /**
32
+ * Returns a function for evaluating the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta`.
33
+ *
34
+ * @param {NonNegativeNumber} alpha - shape parameter
35
+ * @param {PositiveNumber} beta - rate parameter
36
+ * @returns {Function} quantile function
37
+ *
38
+ * @example
39
+ * var quantile = factory( 2.5, 0.5 );
40
+ * var y = quantile( 0.5 );
41
+ * // returns ~4.351
42
+ *
43
+ * y = quantile( 0.8 );
44
+ * // returns ~7.289
45
+ */
46
+ function factory( alpha, beta ) {
47
+ if (
48
+ isnan( alpha ) ||
49
+ isnan( beta ) ||
50
+ alpha < 0.0 ||
51
+ beta <= 0.0
52
+ ) {
53
+ return constantFunction( NaN );
54
+ }
55
+ if ( alpha === 0.0 ) {
56
+ return degenerate( 0.0 );
57
+ }
58
+ return quantile;
59
+
60
+ /**
61
+ * Evaluates the quantile function for a gamma distribution.
62
+ *
63
+ * @private
64
+ * @param {Probability} p - input value
65
+ * @returns {number} evaluated quantile function
66
+ *
67
+ * @example
68
+ * var y = quantile( 0.3 );
69
+ * // returns <number>
70
+ */
71
+ function quantile( p ) {
72
+ if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
73
+ return NaN;
74
+ }
75
+ return ( 1.0 / beta ) * gammaincinv( p, alpha );
76
+ }
77
+ }
78
+
79
+
80
+ // EXPORTS //
81
+
82
+ module.exports = factory;
package/lib/index.js ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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
+ * Gamma distribution quantile function.
23
+ *
24
+ * @module @stdlib/stats-base-dists-gamma-quantile
25
+ *
26
+ * @example
27
+ * var quantile = require( '@stdlib/stats-base-dists-gamma-quantile' );
28
+ *
29
+ * var y = quantile( 0.8, 1.0, 1.0 );
30
+ * // returns ~1.609
31
+ *
32
+ * var myquantile = quantile.factory( 2.0, 2.0 );
33
+ * y = myquantile( 0.8 );
34
+ * // returns ~1.497
35
+ *
36
+ * y = myquantile( 0.4 );
37
+ * // returns ~0.688
38
+ */
39
+
40
+ // MODULES //
41
+
42
+ var setReadOnly = require( '@ohos-ports/stdlib-utils-define-nonenumerable-read-only-property' );
43
+ var main = require( './main.js' );
44
+ var factory = require( './factory.js' );
45
+
46
+
47
+ // MAIN //
48
+
49
+ setReadOnly( main, 'factory', factory );
50
+
51
+
52
+ // EXPORTS //
53
+
54
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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( '@ohos-ports/stdlib-math-base-assert-is-nan' );
24
+ var gammaincinv = require( '@stdlib/math-base-special-gammaincinv' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Evaluates the quantile function for a gamma distribution with shape parameter `alpha` and rate parameter `beta` at a probability `p`.
31
+ *
32
+ * @param {Probability} p - input value
33
+ * @param {NonNegativeNumber} alpha - shape parameter
34
+ * @param {PositiveNumber} beta - rate parameter
35
+ * @returns {number} evaluated quantile function
36
+ *
37
+ * @example
38
+ * var y = quantile( 0.8, 2.0, 1.0 );
39
+ * // returns ~2.994
40
+ *
41
+ * @example
42
+ * var y = quantile( 0.5, 4.0, 2.0 );
43
+ * // returns ~1.836
44
+ *
45
+ * @example
46
+ * var y = quantile( 1.1, 1.0, 1.0 );
47
+ * // returns NaN
48
+ *
49
+ * @example
50
+ * var y = quantile( -0.2, 1.0, 1.0 );
51
+ * // returns NaN
52
+ *
53
+ * @example
54
+ * var y = quantile( NaN, 1.0, 1.0 );
55
+ * // returns NaN
56
+ *
57
+ * @example
58
+ * var y = quantile( 0.0, NaN, 1.0 );
59
+ * // returns NaN
60
+ *
61
+ * @example
62
+ * var y = quantile( 0.0, 1.0, NaN );
63
+ * // returns NaN
64
+ *
65
+ * @example
66
+ * // Non-positive shape parameter:
67
+ * var y = quantile( 0.5, -1.0, 1.0 );
68
+ * // returns NaN
69
+ *
70
+ * @example
71
+ * // Non-positive rate parameter:
72
+ * var y = quantile( 0.5, 1.0, -1.0 );
73
+ * // returns NaN
74
+ */
75
+ function quantile( p, alpha, beta ) {
76
+ if (
77
+ isnan( alpha ) ||
78
+ isnan( beta ) ||
79
+ isnan( p ) ||
80
+ alpha < 0.0 ||
81
+ beta <= 0.0 ||
82
+ p < 0.0 ||
83
+ p > 1.0
84
+ ) {
85
+ return NaN;
86
+ }
87
+ if ( alpha === 0.0 ) {
88
+ return 0.0;
89
+ }
90
+ return ( 1.0 / beta ) * gammaincinv( p, alpha );
91
+ }
92
+
93
+
94
+ // EXPORTS //
95
+
96
+ module.exports = quantile;
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@ohos-ports/stdlib-stats-base-dists-gamma-quantile",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.3-beta.1",
4
+ "description": "Gamma 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
+ "directories": {
18
+ "doc": "./docs",
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": "./docs/types",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/ohos-ports/ohos-ports.git",
28
+ "directory": "ports/stdlib-stats-base-dists-gamma-quantile/0.2.3"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/ohos-ports/ohos-ports/issues"
32
+ },
33
+ "dependencies": {
34
+ "@stdlib/math-base-special-gammaincinv": "^0.2.2",
35
+ "@stdlib/stats-base-dists-degenerate-quantile": "^0.3.1",
36
+ "@stdlib/utils-constant-function": "^0.2.3",
37
+ "@ohos-ports/stdlib-math-base-assert-is-nan": "0.2.3-beta.1",
38
+ "@ohos-ports/stdlib-utils-define-nonenumerable-read-only-property": "^0.2.3-beta.1"
39
+ },
40
+ "devDependencies": {},
41
+ "engines": {
42
+ "node": ">=0.10.0",
43
+ "npm": ">2.7.0"
44
+ },
45
+ "os": [
46
+ "aix",
47
+ "darwin",
48
+ "freebsd",
49
+ "linux",
50
+ "macos",
51
+ "openbsd",
52
+ "sunos",
53
+ "win32",
54
+ "windows",
55
+ "openharmony"
56
+ ],
57
+ "keywords": [
58
+ "stdlib",
59
+ "stdmath",
60
+ "statistics",
61
+ "stats",
62
+ "distribution",
63
+ "dist",
64
+ "probability",
65
+ "cdf",
66
+ "inverse",
67
+ "gamma",
68
+ "univariate",
69
+ "continuous"
70
+ ],
71
+ "funding": {
72
+ "type": "opencollective",
73
+ "url": "https://opencollective.com/stdlib"
74
+ }
75
+ }