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: lectures/prob_dist.md
+25-7Lines changed: 25 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -105,12 +105,10 @@ u = scipy.stats.randint(1, n+1)
105
105
Here's the mean and variance
106
106
107
107
```{code-cell} ipython3
108
-
u.mean()
108
+
u.mean(), u.var()
109
109
```
110
110
111
-
```{code-cell} ipython3
112
-
u.var()
113
-
```
111
+
The formula for the mean is $(n+1)/2$, and the formula for the variance is $(n^2 - 1)/12$.
114
112
115
113
+++ {"user_expressions": []}
116
114
@@ -178,14 +176,22 @@ The interpretation of $p(i)$ is: the number of successes in $n$ independent tria
178
176
179
177
(If $\theta=0.5$, this is "how many heads in $n$ flips of a fair coin")
180
178
181
-
Here's the PDF
179
+
The mean and variance are
182
180
183
181
```{code-cell} ipython3
184
182
n = 10
185
183
θ = 0.5
186
184
u = scipy.stats.binom(n, θ)
187
185
```
188
186
187
+
```{code-cell} ipython3
188
+
u.mean(), u.var()
189
+
```
190
+
191
+
The formula for the mean is $n \theta$ and the formula for the variance is $n \theta (1-\theta)$.
192
+
193
+
Here's the PDF
194
+
189
195
```{code-cell} ipython3
190
196
u.pmf(1)
191
197
```
@@ -220,7 +226,7 @@ plt.show()
220
226
Using `u.pmf`, check that our definition of the CDF given above calculates the same function as `u.cdf`.
221
227
```
222
228
223
-
```{solution-start}mc_ex2
229
+
```{solution-start}prob_ex2
224
230
:class: dropdown
225
231
```
226
232
@@ -251,6 +257,18 @@ $$
251
257
252
258
The interpretation of $p(i)$ is: the number of events in a fixed time interval, where the events occur at a constant rate $\lambda$ and independently of each other.
253
259
260
+
The mean and variance are
261
+
```{code-cell} ipython3
262
+
λ = 2
263
+
u = scipy.stats.poisson(λ)
264
+
```
265
+
266
+
```{code-cell} ipython3
267
+
u.mean(), u.var()
268
+
```
269
+
270
+
The the expectation of Poisson distribution is $\lambda$ and the variance is also $\lambda$.
271
+
254
272
Here's the PMF
255
273
256
274
```{code-cell} ipython3
@@ -312,7 +330,7 @@ Perhaps the most famous distribution is the **normal distribution**, which has d
312
330
313
331
$$
314
332
p(x) = \frac{1}{\sqrt{2\pi}\sigma}
315
-
\exp\left( - \frac{x - \mu}{2\sigma^2}\right)
333
+
\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)
316
334
$$
317
335
318
336
This distribution has two parameters, $\mu$ and $\sigma$.
0 commit comments