@stdlib/stats-base-dists-binomial 0.2.0 → 0.2.2
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/README.md +37 -4
- package/package.json +19 -63
package/README.md
CHANGED
|
@@ -130,10 +130,43 @@ var mu = dist.mean;
|
|
|
130
130
|
<!-- eslint no-undef: "error" -->
|
|
131
131
|
|
|
132
132
|
```javascript
|
|
133
|
-
var objectKeys = require( '@stdlib/utils-keys' );
|
|
134
133
|
var binomial = require( '@stdlib/stats-base-dists-binomial' );
|
|
135
134
|
|
|
136
|
-
|
|
135
|
+
/*
|
|
136
|
+
* Let's take an example of rolling a fair dice 10 times and counting the number of times a 6 is rolled.
|
|
137
|
+
* This situation can be modeled using a Binomial distribution with n = 10 and p = 1/6
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
var n = 10;
|
|
141
|
+
var p = 1/6;
|
|
142
|
+
|
|
143
|
+
// Mean can be used to calculate the average number of times a 6 is rolled:
|
|
144
|
+
console.log( binomial.mean( n, p ) );
|
|
145
|
+
// => ~1.6667
|
|
146
|
+
|
|
147
|
+
// PMF can be used to calculate the probability of getting a certain number of 6s (say 3 sixes):
|
|
148
|
+
console.log( binomial.pmf( 3, n, p ) );
|
|
149
|
+
// => ~0.1550
|
|
150
|
+
|
|
151
|
+
// CDF can be used to calculate probability up to certain number of 6s (say up to 3 sixes):
|
|
152
|
+
console.log( binomial.cdf( 3, n, p ) );
|
|
153
|
+
// => ~0.9303
|
|
154
|
+
|
|
155
|
+
// Quantile can be used to calculate the number of 6s at which you can be 80% confident that the actual number will not exceed.
|
|
156
|
+
console.log( binomial.quantile( 0.8, n, p ) );
|
|
157
|
+
// => 3
|
|
158
|
+
|
|
159
|
+
// Standard deviation can be used to calculate the measure of the spread of 6s around the mean:
|
|
160
|
+
console.log( binomial.stdev( n, p ) );
|
|
161
|
+
// => ~1.1785
|
|
162
|
+
|
|
163
|
+
// Skewness can be used to calculate the asymmetry of the distribution of 6s:
|
|
164
|
+
console.log( binomial.skewness( n, p ) );
|
|
165
|
+
// => ~0.5657
|
|
166
|
+
|
|
167
|
+
// MGF can be used for more advanced statistical analyses and generating moments of the distribution:
|
|
168
|
+
console.log( binomial.mgf( 0.5, n, p ) );
|
|
169
|
+
// => ~2.7917
|
|
137
170
|
```
|
|
138
171
|
|
|
139
172
|
</section>
|
|
@@ -187,8 +220,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
187
220
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-binomial.svg
|
|
188
221
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-binomial
|
|
189
222
|
|
|
190
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-binomial/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
191
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-binomial/actions/workflows/test.yml?query=branch:v0.2.
|
|
223
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-binomial/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
224
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-binomial/actions/workflows/test.yml?query=branch:v0.2.2
|
|
192
225
|
|
|
193
226
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-binomial/main.svg
|
|
194
227
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-binomial?branch=main
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-binomial",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Binomial distribution.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -16,17 +16,11 @@
|
|
|
16
16
|
"main": "./lib",
|
|
17
17
|
"directories": {
|
|
18
18
|
"doc": "./docs",
|
|
19
|
-
"example": "./examples",
|
|
20
19
|
"lib": "./lib",
|
|
21
|
-
"
|
|
20
|
+
"dist": "./dist"
|
|
22
21
|
},
|
|
23
22
|
"types": "./docs/types",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "make test",
|
|
26
|
-
"test-cov": "make test-cov",
|
|
27
|
-
"examples": "make examples",
|
|
28
|
-
"benchmark": "make benchmark"
|
|
29
|
-
},
|
|
23
|
+
"scripts": {},
|
|
30
24
|
"homepage": "https://stdlib.io",
|
|
31
25
|
"repository": {
|
|
32
26
|
"type": "git",
|
|
@@ -36,61 +30,23 @@
|
|
|
36
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
37
31
|
},
|
|
38
32
|
"dependencies": {
|
|
39
|
-
"@stdlib/stats-base-dists-binomial-cdf": "^0.2.
|
|
40
|
-
"@stdlib/stats-base-dists-binomial-ctor": "^0.2.
|
|
41
|
-
"@stdlib/stats-base-dists-binomial-entropy": "^0.2.
|
|
42
|
-
"@stdlib/stats-base-dists-binomial-kurtosis": "^0.2.
|
|
43
|
-
"@stdlib/stats-base-dists-binomial-logpmf": "^0.2.
|
|
44
|
-
"@stdlib/stats-base-dists-binomial-mean": "^0.2.
|
|
45
|
-
"@stdlib/stats-base-dists-binomial-median": "^0.2.
|
|
46
|
-
"@stdlib/stats-base-dists-binomial-mgf": "^0.2.
|
|
47
|
-
"@stdlib/stats-base-dists-binomial-mode": "^0.2.
|
|
48
|
-
"@stdlib/stats-base-dists-binomial-pmf": "^0.2.
|
|
49
|
-
"@stdlib/stats-base-dists-binomial-quantile": "^0.2.
|
|
50
|
-
"@stdlib/stats-base-dists-binomial-skewness": "^0.2.
|
|
51
|
-
"@stdlib/stats-base-dists-binomial-stdev": "^0.2.
|
|
52
|
-
"@stdlib/stats-base-dists-binomial-variance": "^0.2.
|
|
53
|
-
"@stdlib/utils-define-read-only-property": "^0.2.
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@stdlib/assert-has-own-property": "^0.2.0",
|
|
57
|
-
"@stdlib/assert-is-function": "^0.2.0",
|
|
58
|
-
"@stdlib/assert-is-positive-integer": "^0.2.0",
|
|
59
|
-
"@stdlib/assert-is-probability": "^0.2.0",
|
|
60
|
-
"@stdlib/constants-float64-eps": "^0.2.0",
|
|
61
|
-
"@stdlib/constants-float64-ninf": "^0.2.0",
|
|
62
|
-
"@stdlib/constants-float64-pinf": "^0.2.0",
|
|
63
|
-
"@stdlib/constants-float64-sqrt-two": "^0.2.0",
|
|
64
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.0",
|
|
65
|
-
"@stdlib/math-base-assert-is-nonnegative-integer": "^0.2.0",
|
|
66
|
-
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
67
|
-
"@stdlib/math-base-special-betainc": "^0.2.0",
|
|
68
|
-
"@stdlib/math-base-special-binomcoefln": "^0.2.0",
|
|
69
|
-
"@stdlib/math-base-special-ceil": "^0.2.0",
|
|
70
|
-
"@stdlib/math-base-special-erfcinv": "^0.2.0",
|
|
71
|
-
"@stdlib/math-base-special-exp": "^0.2.0",
|
|
72
|
-
"@stdlib/math-base-special-floor": "^0.2.0",
|
|
73
|
-
"@stdlib/math-base-special-ln": "^0.2.0",
|
|
74
|
-
"@stdlib/math-base-special-log1p": "^0.2.0",
|
|
75
|
-
"@stdlib/math-base-special-pow": "^0.2.0",
|
|
76
|
-
"@stdlib/math-base-special-round": "^0.2.0",
|
|
77
|
-
"@stdlib/math-base-special-sqrt": "^0.2.0",
|
|
78
|
-
"@stdlib/random-base-randu": "^0.1.0",
|
|
79
|
-
"@stdlib/stats-base-dists-degenerate-logpmf": "^0.2.0",
|
|
80
|
-
"@stdlib/stats-base-dists-degenerate-pmf": "^0.2.0",
|
|
81
|
-
"@stdlib/stats-base-dists-degenerate-quantile": "^0.2.0",
|
|
82
|
-
"@stdlib/string-format": "^0.2.0",
|
|
83
|
-
"@stdlib/utils-constant-function": "^0.2.0",
|
|
84
|
-
"@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.0",
|
|
85
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
|
|
86
|
-
"@stdlib/utils-define-property": "^0.2.0",
|
|
87
|
-
"@stdlib/utils-keys": "^0.2.0",
|
|
88
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
89
|
-
"istanbul": "^0.4.1",
|
|
90
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
91
|
-
"@stdlib/bench-harness": "^0.2.0",
|
|
92
|
-
"@stdlib/bench": "^0.3.1"
|
|
33
|
+
"@stdlib/stats-base-dists-binomial-cdf": "^0.2.2",
|
|
34
|
+
"@stdlib/stats-base-dists-binomial-ctor": "^0.2.1",
|
|
35
|
+
"@stdlib/stats-base-dists-binomial-entropy": "^0.2.2",
|
|
36
|
+
"@stdlib/stats-base-dists-binomial-kurtosis": "^0.2.2",
|
|
37
|
+
"@stdlib/stats-base-dists-binomial-logpmf": "^0.2.1",
|
|
38
|
+
"@stdlib/stats-base-dists-binomial-mean": "^0.2.2",
|
|
39
|
+
"@stdlib/stats-base-dists-binomial-median": "^0.2.2",
|
|
40
|
+
"@stdlib/stats-base-dists-binomial-mgf": "^0.2.2",
|
|
41
|
+
"@stdlib/stats-base-dists-binomial-mode": "^0.2.2",
|
|
42
|
+
"@stdlib/stats-base-dists-binomial-pmf": "^0.2.2",
|
|
43
|
+
"@stdlib/stats-base-dists-binomial-quantile": "^0.2.2",
|
|
44
|
+
"@stdlib/stats-base-dists-binomial-skewness": "^0.2.2",
|
|
45
|
+
"@stdlib/stats-base-dists-binomial-stdev": "^0.2.2",
|
|
46
|
+
"@stdlib/stats-base-dists-binomial-variance": "^0.2.2",
|
|
47
|
+
"@stdlib/utils-define-read-only-property": "^0.2.2"
|
|
93
48
|
},
|
|
49
|
+
"devDependencies": {},
|
|
94
50
|
"engines": {
|
|
95
51
|
"node": ">=0.10.0",
|
|
96
52
|
"npm": ">2.7.0"
|