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
{{ message }}
Repository navigation
[prob_matrix] Some comments on style and typos #1075
Hi @jstac
I was reading through the prob_matrix lecture and found some potential updates for style and typos.
I'd be grateful if you could take a look when you have a chance.
Conditional probabilities and the discrete bivariate example
State the positive-probability conditions needed by the conditional-probability formulas: $Prob{B}>0$ at lines 426–433; $Prob{Y=j}>0$ for the discrete formula at line 431; $\sum_j\rho_{ij}>0$ for every row constructed at lines 487–494; and $Prob{X(0)=i}=\sum_j f_{ij}>0$ at line 539. At lines 565–566, specify $g_j>0$ and $f_i>0$, respectively, before cancellation. Nonnegative entries summing to one can still have zero row or column sums, so these conditions prevent division by zero.
Distinguish outcome values from array indices at lines 607–608 and in the population tables at lines 693–742. The example uses $X\in{0,1}$ and $Y\in{10,20}$, so write the marginal formulas using the corresponding outcomes $x_i$ and $y_j$, and make the table-label mapping explicit. In Exercise 1, replace line 1585 with: “Compute the marginal distributions $\mu$ of $X$ and $\nu$ of $Y$.” This avoids interpreting the second marginal vector's indices as possible values of $Y$.
Swap the conditioning-variable labels at lines 846–847:
The rows of xctb give the distribution of $X$ conditional on a fixed $Y$, while the rows of yctb give the distribution of $Y$ conditional on a fixed $X$. Their first columns therefore contain $Y$ and $X$ values, respectively.
Rename self.xyp to self.ycp at line 857. The stored array is ycp, so this makes the attribute name consistent with that array and with self.xcp.
Convolution and couplings
At line 1127, write $h_k=(fg)_k$, rather than equating the scalar $h_k$ with the whole convolution sequence. Likewise, at line 1135, write $(f_Xg_Y)(z)$ for the convolution evaluated at $z$. These changes distinguish an entry or function value from the full sequence or function.
At line 1135, replace $f_Y(z-x)$ in the integrand with $g_Y(z-x)$. The density of $Y$ is introduced as $g_Y$, and the convolution on the same line already uses that name.
At line 1192, restrict the parameters to $0<q\le r<1$. Under the current bound $0\le q\le r\le1$, the two displayed couplings coincide when $q=0$ or $r=1$. The revised bound makes the later claim that they are distinct valid throughout the example.
At lines 1200 and 1225, use $[f_{ij}]=$ on the left-hand side of each displayed coupling matrix. A scalar entry $f_{ij}$ is currently equated to the entire matrix; the brackets identify the collection of entries.
```{exercise} Independence test
:label: prob_matrix_ex1```
Apply the same structure at lines 1623, 1681, 1735, and 1781, with the titles “Covariance and correlation,” “Sum of two dice,” “Multi-step transition probabilities,” and “Bayes' law with a discrete prior.” This places each descriptive title alongside its exercise number and gives the exercises a consistent presentation.
After the solution code ending at line 1841, add the verbal interpretation requested in part 4 of Exercise 5: “With three heads instead of seven, the posterior probabilities at $\theta=0.2$ and $\theta=0.8$ exchange places, while the probability at $\theta=0.5$ remains about $0.537$.” The solution computes and plots both posteriors but does not currently describe the shift.
Bold the definitions of “induced probability distribution” (line 113), “marginal distributions” (377), “Conditional probabilities” (420), “transition probability matrix” (491), and “mean” and “variance” (573).
Change bold emphasis to italics for “rate” (196), “all” (202), “information” (301), “big data” (305), “population” (953), “sample” (978), “unique” (1165), “marginal distributions” (1278), “dependence” (1284), and “independent” (1686). This makes the distinction between introducing terminology and emphasizing existing terminology consistent.
[qe-math-003] Use bmatrix for the mathematical vectors and matrices at lines 261–266, 390–395, 500–505, 599–602, 914–920, 1157–1162, 1201–1206, 1226–1231, 1359–1362, and 1436–1439. This follows the math guide's prescribed bmatrix syntax.
[qe-math-010 (proposed)] Standardize expectation and variance notation: replace $\mathbb{D}$ with $\mathbb{V}$ at lines 579, 588, and 1050; replace $\mathrm{E}$ with $\mathbb{E}$ at line 588; and replace $\text{Var}(Z)$ with $\mathbb{V}[Z]$ at line 1694. These changes use the [math guide's designated symbols](https://manual.quantecon.org/styleguide/math.html) for the same operators throughout the lecture.
[qe-math-011 (proposed)] At lines 1015–1016, replace $\mathbb{N}$ with plain $N$ for the normal distribution. The [math guide](https://manual.quantecon.org/styleguide/math.html) uses a plain letter for this distribution name, avoiding confusion with the natural numbers.
[qe-fig-004, qe-fig-005] Add captions and descriptive figure names through mystnb metadata to the figure cells beginning at lines 955, 965, 991, 1000, 1037, 1056, 1071, and 1078, following the [figure guide](https://manual.quantecon.org/styleguide/figures.html). Also change the caption at line 1530 to “Gaussian copula with exponential marginals.” Captions explain what each figure shows, descriptive names support cross-referencing, and “Gaussian” retains its proper-name capitalization.
Hi @jstac
I was reading through the
prob_matrixlecture and found some potential updates for style and typos.I'd be grateful if you could take a look when you have a chance.
Conditional probabilities and the discrete bivariate example
State the positive-probability conditions needed by the conditional-probability formulas:$Prob{B}>0$ at lines 426–433; $Prob{Y=j}>0$ for the discrete formula at line 431; $\sum_j\rho_{ij}>0$ for every row constructed at lines 487–494; and $Prob{X(0)=i}=\sum_j f_{ij}>0$ at line 539. At lines 565–566, specify $g_j>0$ and $f_i>0$ , respectively, before cancellation. Nonnegative entries summing to one can still have zero row or column sums, so these conditions prevent division by zero.
Distinguish outcome values from array indices at lines 607–608 and in the population tables at lines 693–742. The example uses$X\in{0,1}$ and $Y\in{10,20}$ , so write the marginal formulas using the corresponding outcomes $x_i$ and $y_j$ , and make the table-label mapping explicit. In Exercise 1, replace line 1585 with: “Compute the marginal distributions $\mu$ of $X$ and $\nu$ of $Y$ .” This avoids interpreting the second marginal vector's indices as possible values of $Y$ .
Swap the conditioning-variable labels at lines 846–847:
The rows of$X$ conditional on a fixed $Y$ , while the rows of $Y$ conditional on a fixed $X$ . Their first columns therefore contain $Y$ and $X$ values, respectively.
xctbgive the distribution ofyctbgive the distribution ofRename
self.xyptoself.ycpat line 857. The stored array isycp, so this makes the attribute name consistent with that array and withself.xcp.Convolution and couplings
At line 1127, write $h_k=(fg)_k$, rather than equating the scalar $h_k$ with the whole convolution sequence. Likewise, at line 1135, write $(f_Xg_Y)(z)$ for the convolution evaluated at$z$ . These changes distinguish an entry or function value from the full sequence or function.
At line 1135, replace$f_Y(z-x)$ in the integrand with $g_Y(z-x)$ . The density of $Y$ is introduced as $g_Y$ , and the convolution on the same line already uses that name.
At line 1192, restrict the parameters to$0<q\le r<1$ . Under the current bound $0\le q\le r\le1$ , the two displayed couplings coincide when $q=0$ or $r=1$ . The revised bound makes the later claim that they are distinct valid throughout the example.
At lines 1200 and 1225, use$[f_{ij}]=$ on the left-hand side of each displayed coupling matrix. A scalar entry $f_{ij}$ is currently equated to the entire matrix; the brackets identify the collection of entries.
Exercises
Move the five exercise titles into the numbered exercise headings, using the [exercise directive's title argument](https://ebp-sphinx-exercise.readthedocs.io/en/latest/syntax.html#exercise-directive), and remove the separate bold title paragraphs. For example, at line 1572:
Apply the same structure at lines 1623, 1681, 1735, and 1781, with the titles “Covariance and correlation,” “Sum of two dice,” “Multi-step transition probabilities,” and “Bayes' law with a discrete prior.” This places each descriptive title alongside its exercise number and gives the exercises a consistent presentation.
After the solution code ending at line 1841, add the verbal interpretation requested in part 4 of Exercise 5: “With three heads instead of seven, the posterior probabilities at$\theta=0.2$ and $\theta=0.8$ exchange places, while the probability at $\theta=0.5$ remains about $0.537$ .” The solution computes and plots both posteriors but does not currently describe the shift.
Style-related comments
[qe-writing-005] Apply bold formatting to terms where they are defined, and use italics for emphasis, following the [writing guide](https://manual.quantecon.org/styleguide/writing.html).
Bold the definitions of “induced probability distribution” (line 113), “marginal distributions” (377), “Conditional probabilities” (420), “transition probability matrix” (491), and “mean” and “variance” (573).
Change bold emphasis to italics for “rate” (196), “all” (202), “information” (301), “big data” (305), “population” (953), “sample” (978), “unique” (1165), “marginal distributions” (1278), “dependence” (1284), and “independent” (1686). This makes the distinction between introducing terminology and emphasizing existing terminology consistent.
[qe-math-003] Use
bmatrixfor the mathematical vectors and matrices at lines 261–266, 390–395, 500–505, 599–602, 914–920, 1157–1162, 1201–1206, 1226–1231, 1359–1362, and 1436–1439. This follows the math guide's prescribedbmatrixsyntax.[qe-math-010 (proposed)] Standardize expectation and variance notation: replace$\mathbb{D}$ with $\mathbb{V}$ at lines 579, 588, and 1050; replace $\mathrm{E}$ with $\mathbb{E}$ at line 588; and replace $\text{Var}(Z)$ with $\mathbb{V}[Z]$ at line 1694. These changes use the [math guide's designated symbols](https://manual.quantecon.org/styleguide/math.html) for the same operators throughout the lecture.
[qe-math-011 (proposed)] At lines 1015–1016, replace$\mathbb{N}$ with plain $N$ for the normal distribution. The [math guide](https://manual.quantecon.org/styleguide/math.html) uses a plain letter for this distribution name, avoiding confusion with the natural numbers.
[qe-fig-004, qe-fig-005] Add captions and descriptive figure names through
mystnbmetadata to the figure cells beginning at lines 955, 965, 991, 1000, 1037, 1056, 1071, and 1078, following the [figure guide](https://manual.quantecon.org/styleguide/figures.html). Also change the caption at line 1530 to “Gaussian copula with exponential marginals.” Captions explain what each figure shows, descriptive names support cross-referencing, and “Gaussian” retains its proper-name capitalization.[qe-fig-006] Change the axis label
Probabilitytoprobabilityat lines 1722 and 1837. This follows the [figure guide's lowercase-axis-label convention](https://manual.quantecon.org/styleguide/figures.html).[qe-writing-009 (proposed)] Replace “i.i.d.” with “IID” at line 1788. This follows the [writing guide's abbreviation convention](https://manual.quantecon.org/styleguide/writing.html).
What do you think? Happy to put up a PR.
Best,
Longye