Skip to content

Commit 400d8ab

Browse files
jstacclaude
andcommitted
Adopt new style guide notation conventions
Replace \textrm{Prob}(...) with \mathbb{P}{...} and E[...] with \mathbb{E}[...] following QuantEcon.manual#84. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 731fdb2 commit 400d8ab

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

lectures/prob_meaning.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Consider the following classic example.
6868
The random variable $X $ takes on possible values $k = 0, 1, 2, \ldots, n$ with probabilities
6969

7070
$$
71-
\textrm{Prob}(X = k | \theta) =
71+
\mathbb{P}\{X = k \mid \theta\} =
7272
\left(\frac{n!}{k! (n-k)!} \right) \theta^k (1-\theta)^{n-k}
7373
$$
7474

@@ -106,7 +106,7 @@ f_k^I = \frac{\textrm{number of samples of length n for which } \sum_{h=1}^n y_h
106106
I}
107107
$$
108108

109-
The probability $\textrm{Prob}(X = k | \theta)$ answers the following question:
109+
The probability $\mathbb{P}\{X = k \mid \theta\}$ answers the following question:
110110

111111
* As $I$ becomes large, in what fraction of $I$ independent draws of $n$ coin flips should we anticipate $k$ heads to occur?
112112

@@ -118,9 +118,9 @@ As usual, a law of large numbers justifies this answer.
118118
1. Please write a Python class to compute $f_k^I$
119119
120120
2. Please use your code to compute $f_k^I, k = 0, \ldots , n$ and compare them to
121-
$\textrm{Prob}(X = k | \theta)$ for various values of $\theta, n$ and $I$
121+
$\mathbb{P}\{X = k \mid \theta\}$ for various values of $\theta, n$ and $I$
122122
123-
3. With the Law of Large Numbers in mind, use your code to describe the relationship between $f_k^I$ and $\textrm{Prob}(X = k | \theta)$ as $I$ grows
123+
3. With the Law of Large Numbers in mind, use your code to describe the relationship between $f_k^I$ and $\mathbb{P}\{X = k \mid \theta\}$ as $I$ grows
124124
```
125125

126126
```{solution-start} pm_ex1
@@ -293,20 +293,20 @@ From the above graphs, we can see that **$I$, the number of independent sequence
293293
When $I$ becomes larger, the difference between theoretical probability and frequentist estimate becomes smaller.
294294

295295
Also, as long as $I$ is large enough, changing $\theta$ or $n$ does not substantially change the accuracy of the observed fraction
296-
as an approximation of $\textrm{Prob}(X = k | \theta)$.
296+
as an approximation of $\mathbb{P}\{X = k \mid \theta\}$.
297297

298298
The Law of Large Numbers is at work here.
299299

300-
For each draw of an independent sequence, $\textrm{Prob}(X_i = k | \theta)$ is the same, so aggregating all draws forms an IID sequence of a binary random variable $\rho_{k,i},i=1,2,...I$, with a mean of $\textrm{Prob}(X = k | \theta)$ and a variance of
300+
For each draw of an independent sequence, $\mathbb{P}\{X_i = k \mid \theta\}$ is the same, so aggregating all draws forms an IID sequence of a binary random variable $\rho_{k,i},i=1,2,...I$, with a mean of $\mathbb{P}\{X = k \mid \theta\}$ and a variance of
301301

302302
$$
303-
\textrm{Prob}(X = k | \theta) \cdot (1-\textrm{Prob}(X = k | \theta)).
303+
\mathbb{P}\{X = k \mid \theta\} \cdot (1-\mathbb{P}\{X = k \mid \theta\}).
304304
$$
305305

306306
So, by the LLN, the average of $\rho_{k,i}$ converges to:
307307

308308
$$
309-
E[\rho_{k,i}] = \textrm{Prob}(X = k | \theta) = \left(\frac{n!}{k! (n-k)!} \right) \theta^k (1-\theta)^{n-k}
309+
\mathbb{E}[\rho_{k,i}] = \mathbb{P}\{X = k \mid \theta\} = \left(\frac{n!}{k! (n-k)!} \right) \theta^k (1-\theta)^{n-k}
310310
$$
311311

312312
as $I$ goes to infinity.
@@ -343,13 +343,13 @@ We can update this prior after observing data using Bayes' Law (see {doc}`Probab
343343
For a sample of $n$ coin flips that yields $k$ heads, the **likelihood function** is the binomial probability
344344

345345
$$
346-
L(k | \theta) = {n \choose k} \theta^k (1-\theta)^{n-k}
346+
L(k \mid \theta) = {n \choose k} \theta^k (1-\theta)^{n-k}
347347
$$
348348

349349
Applying Bayes' Law with our beta prior, the **posterior density** is
350350

351351
$$
352-
p(\theta | k) = \frac{L(k | \theta) \cdot p(\theta)}{\int_0^1 L(k | \theta) \cdot p(\theta) \, d\theta} = \textrm{Beta}(\alpha + k, \, \beta + n - k)
352+
p(\theta \mid k) = \frac{L(k \mid \theta) \cdot p(\theta)}{\int_0^1 L(k \mid \theta) \cdot p(\theta) \, d\theta} = \textrm{Beta}(\alpha + k, \, \beta + n - k)
353353
$$
354354

355355
So the posterior is also a beta distribution — a consequence of the beta prior being **conjugate** to the binomial likelihood.
@@ -388,25 +388,25 @@ $$
388388
**b)** By Bayes' Law, the posterior density for $\theta$ after observing a single flip $Y$ is
389389

390390
$$
391-
p(\theta | Y) = \frac{L(Y | \theta) \cdot p(\theta)}{\int_{0}^{1} L(Y | \theta) \cdot p(\theta) \, d\theta}
391+
p(\theta \mid Y) = \frac{L(Y \mid \theta) \cdot p(\theta)}{\int_{0}^{1} L(Y \mid \theta) \cdot p(\theta) \, d\theta}
392392
$$
393393

394394
Substituting the likelihood from (a) and the beta prior density, this becomes
395395

396396
$$
397-
p(\theta | Y) = \frac{\theta^Y (1-\theta)^{1-Y} \cdot \theta^{\alpha - 1} (1 - \theta)^{\beta - 1} / B(\alpha, \beta)}{\int_{0}^{1} \theta^Y (1-\theta)^{1-Y} \cdot \theta^{\alpha - 1} (1 - \theta)^{\beta - 1} / B(\alpha, \beta) \, d\theta}
397+
p(\theta \mid Y) = \frac{\theta^Y (1-\theta)^{1-Y} \cdot \theta^{\alpha - 1} (1 - \theta)^{\beta - 1} / B(\alpha, \beta)}{\int_{0}^{1} \theta^Y (1-\theta)^{1-Y} \cdot \theta^{\alpha - 1} (1 - \theta)^{\beta - 1} / B(\alpha, \beta) \, d\theta}
398398
$$
399399

400400
Collecting powers of $\theta$ and $(1-\theta)$, we recognize the kernel of a beta density:
401401

402402
$$
403-
p(\theta | Y) = \frac{\theta^{Y+\alpha - 1} (1 - \theta)^{1-Y+\beta - 1}}{\int_{0}^{1} \theta^{Y+\alpha - 1} (1 - \theta)^{1-Y+\beta - 1} \, d\theta}
403+
p(\theta \mid Y) = \frac{\theta^{Y+\alpha - 1} (1 - \theta)^{1-Y+\beta - 1}}{\int_{0}^{1} \theta^{Y+\alpha - 1} (1 - \theta)^{1-Y+\beta - 1} \, d\theta}
404404
$$
405405

406406
which means that
407407

408408
$$
409-
\theta | Y \sim \textrm{Beta}(\alpha + Y, \, \beta + (1-Y))
409+
\theta \mid Y \sim \textrm{Beta}(\alpha + Y, \, \beta + (1-Y))
410410
$$
411411

412412
**c)**
@@ -656,7 +656,7 @@ So posterior and prior are both beta distributions, albeit ones with different p
656656

657657
When a likelihood function and prior fit together like hand and glove in this way, we can say that the prior and posterior are **conjugate distributions**.
658658

659-
In this situation, we also sometimes say that we have **conjugate prior** for the likelihood function $\textrm{Prob}(X | \theta)$.
659+
In this situation, we also sometimes say that we have **conjugate prior** for the likelihood function $\mathbb{P}\{X \mid \theta\}$.
660660

661661
Typically, the functional form of the likelihood function determines the functional form of a **conjugate prior**.
662662

0 commit comments

Comments
 (0)