This document summarizes the improvements made to chapter_06.md based on the style guide extracted from chapters 3-5.
Visualization Code - Now Hidden
All visualization code that is not part of learning (creating plots to illustrate concepts) is now hidden using :tags: [remove-input, remove-output]:
Examples:
- PMF plot (line ~97)
- CDF plot (line ~169)
- Mean visualization (line ~229)
- Variance visualization (line ~320)
- Y=X² plot (line ~410)
- Empirical vs theoretical comparison plots (line ~487)
Why: These plots support the narrative but don't teach coding skills. Hiding the code keeps the focus on concepts.
Code that demonstrates calculations readers should understand is now in :::{dropdown} Python Implementation blocks:
Examples:
- PMF definition and dictionary creation
- CDF calculation and function definition
- Expected value calculation
- Variance calculation (all three methods)
- Functions of random variables (LOTUS)
Why: Allows readers to see implementation details without interrupting the conceptual flow.
All imports are now in a single cell at the beginning instead of spread across multiple cells.
Before:
import numpy as npimport matplotlib.pyplot as pltAfter:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import rv_discreteThe simulation section now has better separation between:
- Setup (num_simulations, generate data)
- Calculation (mean, variance)
- Display results (comparisons)
Before: Large cells combining setup, calculation, and output
After: Each conceptual step in its own cell
Variance calculations that show equivalent methods are now together in one dropdown instead of scattered across multiple cells.
All figures now have descriptive captions explaining what they show:
Examples:
- "PMF of a fair die roll showing uniform probability of 1/6 for each outcome."
- "CDF of a fair die roll showing the cumulative probability as a step function."
- "Comparison of empirical (simulated) and theoretical distributions, demonstrating convergence."
Why: Helps mobile readers and those using screen readers understand visualizations.
Added blank lines before and after all display math blocks to ensure proper rendering on mobile devices.
Before:
Let's calculate the variance:
$$Var(X) = E[X^2] - (E[X])^2$$
Now we can see...After:
Let's calculate the variance:
$$
Var(X) = E[X^2] - (E[X])^2
$$
Now we can see...Exercises now use consistent dropdown format for answers:
```{admonition} Answer
:class: dropdown
[Answer content here]
\```- claude.md - Comprehensive style guide extracted from chapters 3-5
- chapter_06_improved.md - Improved version of chapter 6
- IMPROVEMENTS_SUMMARY.md - This file
The improved chapter will generate these SVG files:
ch06_pmf_die.svgch06_cdf_die.svgch06_pmf_with_mean.svgch06_pmf_with_std.svgch06_pmf_y_squared.svgch06_empirical_vs_theoretical.svg
-
Build intuition first, then formalize - Each concept follows: intuition → visual → definition → example → code
-
Hide non-learning code - Visualization code is hidden; learning code is in dropdowns
-
Split cells logically - Each cell represents one conceptual unit or one output
-
Use admonitions strategically - Dropdowns for examples, notes for terminology, tips for insights
-
Mobile-friendly formatting - Blank lines around math, appropriate figure widths
-
Clear progression - Introduction → concepts → hands-on → summary → exercises
- Cleaner reading experience - Less code clutter in the main narrative
- Optional depth - Can expand dropdowns to see implementation details
- Better mobile experience - Proper math rendering and figure captions
- Consistent structure - Same patterns across chapters
- Clear guidelines - claude.md provides explicit patterns to follow
- Easier updates - Consistent structure makes changes predictable
- Quality control - Checklist in style guide ensures completeness
Before: ~30 visible code cells throughout the chapter After: ~15 visible code cells (learning/hands-on), ~6 hidden cells (visualization)
Before: Minimal use of dropdowns After: 6 dropdown blocks for implementation details
Before: Figures without captions or context After: All figures have descriptive captions and proper sizing
To apply the improved version:
- Review
chapter_06_improved.md - Test by converting to Jupyter notebook:
jupytext --to ipynb chapter_06_improved.md - Run all cells and verify outputs
- If satisfied, replace original:
mv chapter_06_improved.md chapter_06.md - Apply similar patterns to other chapters using
claude.mdas reference
- Start with claude.md - Review the style guide before writing
- Use the checklist - The quality checklist ensures nothing is missed
- Be consistent - Follow the same patterns for the same types of content
- Test on mobile - Verify math rendering and figure display
Consider reviewing chapters 1-2 and 7+ to apply these patterns consistently across the entire book.