Commit 8e74ab4
Add Bivariate Distributions lecture (#837)
* Add Bivariate Distributions lecture
Adds a new lecture introducing bivariate distributions, placed after
fitting_distributions and before lln_clt in the Probability and
Distributions part of the toc.
Covers joint/marginal distributions (discrete and continuous), independence,
covariance and correlation, ways joint distributions arise (independent
components; Y = aX + b + U), the bivariate normal distribution, and a
counterexample showing normal marginals don't imply joint normality. Moves
to observed data using the Ames house price dataset already used in
observed_distributions/fitting_distributions, fits a bivariate normal by
the method of moments, and closes with a preview showing the bivariate
normal's conditional mean coincides with the OLS line, handing off to
simple_linear_regression.
Built and rendered locally to verify execution and output.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Restructure flow: fold marginals into discrete/continuous cases
- Move marginal distributions into the Discrete case and Continuous case
subsections directly, rather than as a separate section after both, so
discrete marginals (sums, bar charts) come first and continuous marginals
(integrals, density curves) mirror them.
- Split the Ames discrete example by mean instead of median, so the
marginals are visibly asymmetric (~45%/38%) rather than ~50/50 by
construction, tying back to the right-skew lesson from
observed_distributions.
- Add a heatmap of the joint PMF in the discrete case, and introduce the
bivariate normal density (with 3D surface and contour plots) directly in
the continuous case rather than in a separate later section.
- Rename "The bivariate normal distribution" to "Back to the normal
distribution", now picking up after Independence/Covariance/How joint
distributions arise with the properties note, sample-draws figure, and
the "word of caution" counterexample.
- Explain what np.corrcoef returns and why [0, 1] is indexed, the first
time it's used.
- In "A word of caution": use 1 directly instead of an unnecessary
parameter c, fix a leftover "houses" reference from the Ames example,
and switch the counterexample to sns.jointplot so the normal marginals
and non-normal joint are visible in one figure.
Re-executed the full notebook (31 code cells) after each change; verified
with a local jupyter-book build.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Fix heatmap y-axis orientation to read as positive correlation
sns.heatmap puts row 0 at the top by default, so with x=0 (below mean)
at the top and x=1 (above mean) at the bottom, the diagonal of large
cells ran top-left to bottom-right --- visually reading as a negative
correlation even though the data is positively correlated. Add
ax.invert_yaxis() to both heatmaps (the discrete joint heatmap and the
actual-vs-independent comparison) so x increases upward, matching how
a standard scatter plot reads.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent 9b1dadc commit 8e74ab4
2 files changed
Lines changed: 842 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
0 commit comments