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
+19-19
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Hence the second term takes all $x_i \leq x$ and sums their probabilities.
86
86
87
87
#### Uniform distribution
88
88
89
-
One simple example is the **uniform distribution**, where $p(x_i) = 1/n$ for all $n$.
89
+
One simple example is the **uniform distribution**, where $p(x_i) = 1/n$ for all $i$.
90
90
91
91
We can import the uniform distribution on $S = \{1, \ldots, n\}$ from SciPy like so:
92
92
@@ -96,7 +96,7 @@ u = scipy.stats.randint(1, n+1)
96
96
```
97
97
98
98
99
-
Here's the mean and variance
99
+
Here's the mean and variance:
100
100
101
101
```{code-cell} ipython3
102
102
u.mean(), u.var()
@@ -105,7 +105,7 @@ u.mean(), u.var()
105
105
The formula for the mean is $(n+1)/2$, and the formula for the variance is $(n^2 - 1)/12$.
106
106
107
107
108
-
Now let's evaluate the PMF
108
+
Now let's evaluate the PMF:
109
109
110
110
```{code-cell} ipython3
111
111
u.pmf(1)
@@ -140,7 +140,7 @@ plt.show()
140
140
```
141
141
142
142
143
-
The CDF jumps up by $p(x_i)$ and $x_i$.
143
+
The CDF jumps up by $p(x_i)$ at $x_i$.
144
144
145
145
146
146
```{exercise}
@@ -194,19 +194,19 @@ u.pmf(1)
194
194
195
195
#### Binomial distribution
196
196
197
-
Another useful (and more interesting) distribution is the **binomial distribution** on $S=\{0, \ldots, n\}$, which has PMF
197
+
Another useful (and more interesting) distribution is the **binomial distribution** on $S=\{0, \ldots, n\}$, which has PMF:
198
198
199
199
$$
200
200
p(i) = \binom{n}{i} \theta^i (1-\theta)^{n-i}
201
201
$$
202
202
203
203
Here $\theta \in [0,1]$ is a parameter.
204
204
205
-
The interpretation of $p(i)$ is: the number of successes in $n$ independent trials with success probability $\theta$.
205
+
The interpretation of $p(i)$ is: the probability of $i$ successes in $n$ independent trials with success probability $\theta$.
206
206
207
-
(If $\theta=0.5$, p(i) can be "how many heads in $n$ flips of a fair coin")
207
+
(If $\theta=0.5$, p(i) can be the probability of $i$ heads in $n$ flips of a fair coin.)
208
208
209
-
The mean and variance are
209
+
The mean and variance are:
210
210
211
211
```{code-cell} ipython3
212
212
n = 10
@@ -220,7 +220,7 @@ u.mean(), u.var()
220
220
221
221
The formula for the mean is $n \theta$ and the formula for the variance is $n \theta (1-\theta)$.
222
222
223
-
Here's the PDF
223
+
Here's the PMF:
224
224
225
225
```{code-cell} ipython3
226
226
u.pmf(1)
@@ -236,7 +236,7 @@ plt.show()
236
236
```
237
237
238
238
239
-
Here's the CDF
239
+
Here's the CDF:
240
240
241
241
```{code-cell} ipython3
242
242
fig, ax = plt.subplots()
@@ -258,7 +258,7 @@ Using `u.pmf`, check that our definition of the CDF given above calculates the s
258
258
:class: dropdown
259
259
```
260
260
261
-
Here is one solution
261
+
Here is one solution:
262
262
263
263
```{code-cell} ipython3
264
264
fig, ax = plt.subplots()
@@ -283,9 +283,9 @@ $$
283
283
p(i) = \frac{\lambda^i}{i!} e^{-\lambda}
284
284
$$
285
285
286
-
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.
286
+
The interpretation of $p(i)$ is: the probability of $i$ events in a fixed time interval, where the events occur at a constant rate $\lambda$ and independently of each other.
287
287
288
-
The mean and variance are
288
+
The mean and variance are:
289
289
```{code-cell} ipython3
290
290
λ = 2
291
291
u = scipy.stats.poisson(λ)
@@ -297,7 +297,7 @@ u.mean(), u.var()
297
297
298
298
The the expectation of Poisson distribution is $\lambda$ and the variance is also $\lambda$.
299
299
300
-
Here's the PMF
300
+
Here's the PMF:
301
301
302
302
```{code-cell} ipython3
303
303
λ = 2
@@ -321,7 +321,7 @@ plt.show()
321
321
### Continuous distributions
322
322
323
323
324
-
Continuous distributions are represented by a **density function**, which is a function $p$ over $\mathbb R$ (the set of all numbers) such that $p(x) \geq 0$ for all $x$ and
324
+
Continuous distributions are represented by a **probability density function**, which is a function $p$ over $\mathbb R$ (the set of all real numbers) such that $p(x) \geq 0$ for all $x$ and
325
325
326
326
$$ \int_{-\infty}^\infty p(x) dx = 1 $$
327
327
@@ -424,7 +424,7 @@ It has a nice interpretation: if $X$ is lognormally distributed, then $\log X$ i
424
424
425
425
It is often used to model variables that are "multiplicative" in nature, such as income or asset prices.
426
426
427
-
We can obtain the moments, PDF, and CDF of the normal density as follows:
427
+
We can obtain the moments, PDF, and CDF of the lognormal density as follows:
428
428
429
429
```{code-cell} ipython3
430
430
μ, σ = 0.0, 1.0
@@ -479,7 +479,7 @@ It is related to the Poisson distribution as it describes the distribution of th
479
479
480
480
It can be shown that, for this distribution, the mean is $1/\lambda$ and the variance is $1/\lambda^2$.
481
481
482
-
We can obtain the moments, PDF, and CDF of the normal density as follows:
482
+
We can obtain the moments, PDF, and CDF of the exponential density as follows:
483
483
484
484
```{code-cell} ipython3
485
485
λ = 1.0
@@ -535,7 +535,7 @@ This distribution has two parameters, $\alpha > 0$ and $\beta > 0$.
535
535
It can be shown that, for this distribution, the mean is $\alpha / (\alpha + \beta)$ and
536
536
the variance is $\alpha \beta / (\alpha + \beta)^2 (\alpha + \beta + 1)$.
537
537
538
-
We can obtain the moments, PDF, and CDF of the normal density as follows:
538
+
We can obtain the moments, PDF, and CDF of the Beta density as follows:
539
539
540
540
```{code-cell} ipython3
541
541
α, β = 3.0, 1.0
@@ -592,7 +592,7 @@ One interpretation is that if $X$ is gamma distributed and $\alpha$ is an
592
592
integer, then $X$ is the sum of $\alpha$ independent exponentially distributed
593
593
random variables with mean $1/\beta$.
594
594
595
-
We can obtain the moments, PDF, and CDF of the normal density as follows:
595
+
We can obtain the moments, PDF, and CDF of the Gamma density as follows:
0 commit comments