You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
<section class="release" id="unreleased">
6
6
7
-
## Unreleased (2024-06-06)
7
+
## Unreleased (2024-06-08)
8
8
9
9
<section class="packages">
10
10
@@ -54,11 +54,12 @@ This release closes the following issue:
54
54
55
55
### Contributors
56
56
57
-
A total of 6 people contributed to this release. Thank you to the following contributors:
57
+
A total of 7 people contributed to this release. Thank you to the following contributors:
58
58
59
59
- Athan Reines
60
60
- Jaimin Godhani
61
61
- Muhammad Haris
62
+
- NightKnight
62
63
- Philipp Burckhardt
63
64
- Rejoan Sardar
64
65
- nishant-s7
@@ -73,6 +74,7 @@ A total of 6 people contributed to this release. Thank you to the following cont
73
74
74
75
<details>
75
76
77
+
- [`922122e`](https://github.com/stdlib-js/stdlib/commit/922122e319c37170f16e14ce5d074273fd7f0675) - **docs:** improve examples for `stats/base/dists/normal` namespace _(by NightKnight, Philipp Burckhardt)_
76
78
- [`c3ebfa8`](https://github.com/stdlib-js/stdlib/commit/c3ebfa80e311db338b171ebf8eb5f46bc66e9bf6) - **docs:** update namespace table of contents and address spelling errors _(by Philipp Burckhardt)_
77
79
- [`ac73b91`](https://github.com/stdlib-js/stdlib/commit/ac73b9195cf4f4e087dca2df535ac49831e1aa07) - **docs:** satisfy spellchecker _(by Philipp Burckhardt)_
78
80
- [`867726b`](https://github.com/stdlib-js/stdlib/commit/867726bb7ef6851ca0986ecdb91bf5a5f246ee5a) - **docs:** update examples in `stats/base/dists/uniform` _(by Muhammad Haris, Philipp Burckhardt)_
Copy file name to clipboardExpand all lines: base/dists/normal/README.md
+101-2
Original file line number
Diff line number
Diff line change
@@ -109,12 +109,111 @@ var y = dist.pdf( 2.0 );
109
109
<!-- eslint no-undef: "error" -->
110
110
111
111
```javascript
112
-
var objectKeys =require( '@stdlib/utils/keys' );
113
112
var normal =require( '@stdlib/stats/base/dists/normal' );
114
113
115
-
console.log( objectKeys( normal ) );
114
+
/*
115
+
A bakery is analyzing cake baking times to ensure consistency and better schedule their baking processes.
116
+
117
+
The Central Limit Theorem (CLT) states that the average baking times from many batches will follow a normal distribution if there are enough batches (typically n > 30).
118
+
119
+
Assuming each record represents the average baking time per batch and the bakery has collected the following data:
120
+
121
+
- Mean baking time (μ/mu): 20 minutes.
122
+
- Standard deviation in baking time (σ/sigma): 3 minutes.
123
+
124
+
We can model the average bake times using a normal distribution with μ (mu) = 20.0 minutes and σ = 3.0 minutes.
125
+
*/
126
+
127
+
var mu =20.0;
128
+
var sigma =3.0;
129
+
130
+
var normalDist =newnormal.Normal( mu, sigma );
131
+
132
+
// Output the standard deviation of the baking times:
133
+
console.log( normalDist.sigma );
134
+
// => 3.0
135
+
136
+
// Adjust distribution parameters
137
+
normalDist.sigma=4.0;
138
+
139
+
// Adjusted standard deviation to reflect different variance scenario:
140
+
console.log( normalDist.sigma );
141
+
// => 4.0
142
+
143
+
// Excess kurtosis of a normal distribution (measure of "tailedness"):
144
+
console.log( normalDist.kurtosis );
145
+
// => 0.0
146
+
147
+
// Median baking time:
148
+
console.log( normalDist.median );
149
+
// => 20.0
150
+
151
+
// Variance of the baking times after adjusting sigma:
152
+
console.log( normalDist.variance );
153
+
// => 16.0
154
+
155
+
// Probability density function at the mean baking time:
156
+
console.log( normal.pdf( 20.0, mu, sigma ) );
157
+
// => ~0.133
158
+
159
+
// Cumulative distribution function at the mean (portion of times ≤ 20 minutes):
160
+
console.log( normal.cdf( 20.0, mu, sigma ) );
161
+
// => ~0.5
162
+
163
+
// 50th percentile (median) of the baking times:
164
+
console.log( normal.quantile( 0.5, mu, sigma ) );
165
+
// => 20.0
166
+
167
+
// Moment-generating function value at 0.5 (used in probability theory):
168
+
console.log( normal.mgf( 0.5, mu, sigma ) );
169
+
// => ~67846.291
170
+
171
+
// Entropy of the normal distribution (measure of uncertainty):
172
+
console.log( normal.entropy( mu, sigma ) );
173
+
// => ~2.518
174
+
175
+
// Mean baking time:
176
+
console.log( normal.mean( mu, sigma ) );
177
+
// => 20.0
178
+
179
+
// Median baking time:
180
+
console.log( normal.median( mu, sigma ) );
181
+
// => 20.0
182
+
183
+
// Mode of the baking times (most frequent value):
184
+
console.log( normal.mode( mu, sigma ) );
185
+
// => 20.0
186
+
187
+
// Variance of the baking times:
188
+
console.log( normal.variance( mu, sigma ) );
189
+
// => 9.0
190
+
191
+
// Skewness of the distribution (symmetry measure):
192
+
console.log( normal.skewness( mu, sigma ) );
193
+
// => 0.0
194
+
195
+
var myquantile =normal.quantile.factory( 20.0, 3.0 );
196
+
197
+
// 20th percentile (value below which 20% baking times fall):
198
+
console.log( myquantile( 0.2 ) );
199
+
// => ~17.475
200
+
201
+
// 80th percentile (value below which 80% baking times fall):
202
+
console.log( myquantile( 0.8 ) );
203
+
// => ~22.525
204
+
205
+
var mylogpdf =normal.logpdf.factory( 20.0, 3.0 );
206
+
207
+
// Logarithm of the probability density function at the mean:
208
+
console.log( mylogpdf( 20.0 ) );
209
+
// => ~-2.018
210
+
211
+
// Logarithm of the probability density function at 15 minutes:
Copy file name to clipboardExpand all lines: base/dists/normal/examples/index.js
+100-2
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,105 @@
18
18
19
19
'use strict';
20
20
21
-
varobjectKeys=require('@stdlib/utils/keys');
22
21
varnormal=require('./../lib');
23
22
24
-
console.log(objectKeys(normal));
23
+
/*
24
+
A bakery is analyzing cake baking times to ensure consistency and better schedule their baking processes.
25
+
26
+
The Central Limit Theorem (CLT) states that the average baking times from many batches will follow a normal distribution if there are enough batches (typically n > 30).
27
+
28
+
Assuming each record represents the average baking time per batch and the bakery has collected the following data:
29
+
30
+
- Mean baking time (μ/mu): 20 minutes.
31
+
- Standard deviation in baking time (σ/sigma): 3 minutes.
32
+
33
+
We can model the average bake times using a normal distribution with μ (mu) = 20.0 minutes and σ = 3.0 minutes.
34
+
*/
35
+
36
+
varmu=20.0;
37
+
varsigma=3.0;
38
+
39
+
varnormalDist=newnormal.Normal(mu,sigma);
40
+
41
+
// Output the standard deviation of the baking times:
42
+
console.log(normalDist.sigma);
43
+
// => 3.0
44
+
45
+
// Adjust distribution parameters
46
+
normalDist.sigma=4.0;
47
+
48
+
// Adjusted standard deviation to reflect different variance scenario:
49
+
console.log(normalDist.sigma);
50
+
// => 4.0
51
+
52
+
// Excess kurtosis of a normal distribution (measure of "tailedness"):
53
+
console.log(normalDist.kurtosis);
54
+
// => 0.0
55
+
56
+
// Median baking time:
57
+
console.log(normalDist.median);
58
+
// => 20.0
59
+
60
+
// Variance of the baking times after adjusting sigma:
61
+
console.log(normalDist.variance);
62
+
// => 16.0
63
+
64
+
// Probability density function at the mean baking time:
65
+
console.log(normal.pdf(20.0,mu,sigma));
66
+
// => ~0.133
67
+
68
+
// Cumulative distribution function at the mean (portion of times ≤ 20 minutes):
69
+
console.log(normal.cdf(20.0,mu,sigma));
70
+
// => ~0.5
71
+
72
+
// 50th percentile (median) of the baking times:
73
+
console.log(normal.quantile(0.5,mu,sigma));
74
+
// => 20.0
75
+
76
+
// Moment-generating function value at 0.5 (used in probability theory):
77
+
console.log(normal.mgf(0.5,mu,sigma));
78
+
// => ~67846.291
79
+
80
+
// Entropy of the normal distribution (measure of uncertainty):
81
+
console.log(normal.entropy(mu,sigma));
82
+
// => ~2.518
83
+
84
+
// Mean baking time:
85
+
console.log(normal.mean(mu,sigma));
86
+
// => 20.0
87
+
88
+
// Median baking time:
89
+
console.log(normal.median(mu,sigma));
90
+
// => 20.0
91
+
92
+
// Mode of the baking times (most frequent value):
93
+
console.log(normal.mode(mu,sigma));
94
+
// => 20.0
95
+
96
+
// Variance of the baking times:
97
+
console.log(normal.variance(mu,sigma));
98
+
// => 9.0
99
+
100
+
// Skewness of the distribution (symmetry measure):
101
+
console.log(normal.skewness(mu,sigma));
102
+
// => 0.0
103
+
104
+
varmyquantile=normal.quantile.factory(20.0,3.0);
105
+
106
+
// 20th percentile (value below which 20% baking times fall):
107
+
console.log(myquantile(0.2));
108
+
// => ~17.475
109
+
110
+
// 80th percentile (value below which 80% baking times fall):
111
+
console.log(myquantile(0.8));
112
+
// => ~22.525
113
+
114
+
varmylogpdf=normal.logpdf.factory(20.0,3.0);
115
+
116
+
// Logarithm of the probability density function at the mean:
117
+
console.log(mylogpdf(20.0));
118
+
// => ~-2.018
119
+
120
+
// Logarithm of the probability density function at 15 minutes:
0 commit comments