@stdlib/stats-base-dists-beta-quantile 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +16 -20
- package/dist/index.js.map +1 -1
- package/docs/types/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +5 -5
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ The [quantile function][quantile-function] for a [beta][beta-distribution] rando
|
|
|
48
48
|
|
|
49
49
|
<!-- </equation> -->
|
|
50
50
|
|
|
51
|
-
for `0 <= p <= 1`, where
|
|
51
|
+
for `0 <= p <= 1`, where `α > 0` is the first shape parameter and `β > 0` is the second shape parameter and `F(x;α,β)` denotes the cumulative distribution function of a [beta][beta-distribution] random variable with parameters `α` and `β`.
|
|
52
52
|
|
|
53
53
|
</section>
|
|
54
54
|
|
|
@@ -152,23 +152,19 @@ y = myquantile( 0.4 );
|
|
|
152
152
|
<!-- eslint no-undef: "error" -->
|
|
153
153
|
|
|
154
154
|
```javascript
|
|
155
|
-
var
|
|
155
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
156
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
156
157
|
var EPS = require( '@stdlib/constants-float64-eps' );
|
|
157
158
|
var quantile = require( '@stdlib/stats-base-dists-beta-quantile' );
|
|
158
159
|
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
alpha = ( randu()*5.0 ) + EPS;
|
|
168
|
-
beta = ( randu()*5.0 ) + EPS;
|
|
169
|
-
y = quantile( p, alpha, beta );
|
|
170
|
-
console.log( 'p: %d, α: %d, β: %d, Q(p;α,β): %d', p.toFixed( 4 ), alpha.toFixed( 4 ), beta.toFixed( 4 ), y.toFixed( 4 ) );
|
|
171
|
-
}
|
|
160
|
+
var opts = {
|
|
161
|
+
'dtype': 'float64'
|
|
162
|
+
};
|
|
163
|
+
var alpha = uniform( 10, EPS, 5.0, opts );
|
|
164
|
+
var beta = uniform( 10, EPS, 5.0, opts );
|
|
165
|
+
var p = uniform( 10, 0.0, 1.0, opts );
|
|
166
|
+
|
|
167
|
+
logEachMap( 'p: %0.4f, α: %0.4f, β: %0.4f, Q(p;α,β): %0.4f', p, alpha, beta, quantile );
|
|
172
168
|
```
|
|
173
169
|
|
|
174
170
|
</section>
|
|
@@ -209,7 +205,7 @@ See [LICENSE][stdlib-license].
|
|
|
209
205
|
|
|
210
206
|
## Copyright
|
|
211
207
|
|
|
212
|
-
Copyright © 2016-
|
|
208
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
213
209
|
|
|
214
210
|
</section>
|
|
215
211
|
|
|
@@ -222,8 +218,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
222
218
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-beta-quantile.svg
|
|
223
219
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-beta-quantile
|
|
224
220
|
|
|
225
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-beta-quantile/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
226
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-beta-quantile/actions/workflows/test.yml?query=branch:v0.2.
|
|
221
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-beta-quantile/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
222
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-beta-quantile/actions/workflows/test.yml?query=branch:v0.2.3
|
|
227
223
|
|
|
228
224
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-beta-quantile/main.svg
|
|
229
225
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-beta-quantile?branch=main
|
|
@@ -235,8 +231,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
235
231
|
|
|
236
232
|
-->
|
|
237
233
|
|
|
238
|
-
[chat-image]: https://img.shields.io/
|
|
239
|
-
[chat-url]: https://
|
|
234
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
235
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
240
236
|
|
|
241
237
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
242
238
|
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 betaincinv = require( '@stdlib/math-base-special-betaincinv' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Evaluates the quantile function for a beta distribution with first shape parameter `alpha` and second shape parameter `beta` at a probability `p`.\n*\n* @param {Probability} p - input value\n* @param {PositiveNumber} alpha - first shape parameter\n* @param {PositiveNumber} beta - second shape parameter\n* @returns {number} evaluated quantile function\n*\n* @example\n* var y = quantile( 0.8, 2.0, 1.0 );\n* // returns ~0.894\n*\n* @example\n* var y = quantile( 0.5, 4.0, 2.0 );\n* // returns ~0.686\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.5, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, 1.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, -1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, 1.0, -1.0 );\n* // returns NaN\n*/\nfunction quantile( p, alpha, beta ) {\n\tif (\n\t\tisnan( p ) ||\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\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\treturn betaincinv( p, alpha, beta );\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 betaincinv = require( '@stdlib/math-base-special-betaincinv' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the quantile function for a beta distribution with first shape parameter `alpha` and second shape parameter `beta`.\n*\n* @param {PositiveNumber} alpha - first shape parameter\n* @param {PositiveNumber} beta - second shape 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 ~0.904\n*\n* y = quantile( 0.8 );\n* // returns ~0.986\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\treturn quantile;\n\n\t/**\n\t* Evaluates the quantile function for a beta 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 (\n\t\t\tisnan( p ) ||\n\t\t\tp < 0.0 ||\n\t\t\tp > 1.0\n\t\t) {\n\t\t\treturn NaN;\n\t\t}\n\t\treturn betaincinv( p, alpha, beta );\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* Evaluate the quantile function for a beta distribution.\n*\n* @module @stdlib/stats-base-dists-beta-quantile\n*\n* @example\n* var quantile = require( '@stdlib/stats-base-dists-beta-quantile' );\n*\n* var y = quantile( 0.8, 2.0, 1.0 );\n* // returns ~0.894\n*\n* y = quantile( 0.5, 4.0, 2.0 );\n* // returns ~0.686\n*\n* @example\n* var factory = require( '@stdlib/stats-base-dists-beta-quantile' ).factory;\n*\n* var quantile = factory( 2.0, 2.0 );\n*\n* var y = quantile( 0.8 );\n* // returns ~0.713\n*\n* y = quantile( 0.4 );\n* // returns ~0.
|
|
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 betaincinv = require( '@stdlib/math-base-special-betaincinv' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Evaluates the quantile function for a beta distribution with first shape parameter `alpha` and second shape parameter `beta` at a probability `p`.\n*\n* @param {Probability} p - input value\n* @param {PositiveNumber} alpha - first shape parameter\n* @param {PositiveNumber} beta - second shape parameter\n* @returns {number} evaluated quantile function\n*\n* @example\n* var y = quantile( 0.8, 2.0, 1.0 );\n* // returns ~0.894\n*\n* @example\n* var y = quantile( 0.5, 4.0, 2.0 );\n* // returns ~0.686\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.5, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, 1.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, -1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = quantile( 0.5, 1.0, -1.0 );\n* // returns NaN\n*/\nfunction quantile( p, alpha, beta ) {\n\tif (\n\t\tisnan( p ) ||\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\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\treturn betaincinv( p, alpha, beta );\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 betaincinv = require( '@stdlib/math-base-special-betaincinv' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the quantile function for a beta distribution with first shape parameter `alpha` and second shape parameter `beta`.\n*\n* @param {PositiveNumber} alpha - first shape parameter\n* @param {PositiveNumber} beta - second shape 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 ~0.904\n*\n* y = quantile( 0.8 );\n* // returns ~0.986\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\treturn quantile;\n\n\t/**\n\t* Evaluates the quantile function for a beta 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 (\n\t\t\tisnan( p ) ||\n\t\t\tp < 0.0 ||\n\t\t\tp > 1.0\n\t\t) {\n\t\t\treturn NaN;\n\t\t}\n\t\treturn betaincinv( p, alpha, beta );\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* Evaluate the quantile function for a beta distribution.\n*\n* @module @stdlib/stats-base-dists-beta-quantile\n*\n* @example\n* var quantile = require( '@stdlib/stats-base-dists-beta-quantile' );\n*\n* var y = quantile( 0.8, 2.0, 1.0 );\n* // returns ~0.894\n*\n* y = quantile( 0.5, 4.0, 2.0 );\n* // returns ~0.686\n*\n* @example\n* var factory = require( '@stdlib/stats-base-dists-beta-quantile' ).factory;\n*\n* var quantile = factory( 2.0, 2.0 );\n*\n* var y = quantile( 0.8 );\n* // returns ~0.713\n*\n* y = quantile( 0.4 );\n* // returns ~0.433\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
5
|
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,sCAAuC,EAC7DC,EAAQ,QAAS,iCAAkC,EAiDvD,SAASC,EAAUC,EAAGC,EAAOC,EAAO,CACnC,OACCJ,EAAOE,CAAE,GACTF,EAAOG,CAAM,GACbH,EAAOI,CAAK,GACZD,GAAS,GACTC,GAAQ,GACRF,EAAI,GACJA,EAAI,EAEG,IAEDH,EAAYG,EAAGC,EAAOC,CAAK,CACnC,CAKAN,EAAO,QAAUG,IC1FjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAa,QAAS,sCAAuC,EAC7DC,EAAQ,QAAS,iCAAkC,EAoBvD,SAASC,EAASC,EAAOC,EAAO,CAC/B,GACCH,EAAOE,CAAM,GACbF,EAAOG,CAAK,GACZD,GAAS,GACTC,GAAQ,EAER,OAAOL,EAAkB,GAAI,EAE9B,OAAOM,EAaP,SAASA,EAAUC,EAAI,CACtB,OACCL,EAAOK,CAAE,GACTA,EAAI,GACJA,EAAI,EAEG,IAEDN,EAAYM,EAAGH,EAAOC,CAAK,CACnC,CACD,CAKAN,EAAO,QAAUI,ICjCjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "betaincinv", "isnan", "quantile", "p", "alpha", "beta", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "betaincinv", "isnan", "factory", "alpha", "beta", "quantile", "p", "setReadOnly", "main", "factory"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-beta-quantile",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Beta distribution quantile function.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.
|
|
34
|
-
"@stdlib/math-base-special-betaincinv": "^0.2.
|
|
35
|
-
"@stdlib/utils-constant-function": "^0.2.
|
|
36
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.
|
|
33
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.3",
|
|
34
|
+
"@stdlib/math-base-special-betaincinv": "^0.2.2",
|
|
35
|
+
"@stdlib/utils-constant-function": "^0.2.3",
|
|
36
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {},
|
|
39
39
|
"engines": {
|