Histogram convergence to the true PDF — N(3, 1)

As you draw more samples and use thinner bars, the histogram approaches the smooth bell curve. The tallest bar converges to the PDF peak at x = 3.

505002k10k50k500k
52050100200
Histogram
True PDF — N(3, 1)
Tallest bar (x ≈ 3)

What is the "mode" — and what does this plot show?

Discrete Mode in a histogram
When data is binned into bars, the mode is the tallest bar — the bin that contains the most observations. It is the most frequently occurring range of values, not a single number. Here, the orange bar is always the tallest, and it sits near x = 3. With fewer samples or wide bins, the tallest bar may wander slightly — that is sampling noise, not a property of the distribution.
Continuous Mode of a PDF
For a continuous distribution, the mode is the x-value where the PDF reaches its peak — the highest point on the smooth curve. For N(μ, σ²) the mode equals the mean μ. Here μ = 3, so the red curve peaks exactly at x = 3. Unlike the discrete case, this is a precise real number, not a bin.
The bridge between the two: As you increase the sample count and shrink the bin width simultaneously, the discrete histogram mode (orange bar center) converges to the continuous PDF mode (peak of the red curve). This is the Law of Large Numbers made visible — infinitely many infinitely thin bars become the smooth curve.

Reading this plot — step by step

📊
Blue bars = your data
Each bar height is a density: count ÷ (n × bin width). This rescales so the total area = 1, matching the PDF scale.
🟠
Orange bar = discrete mode
The tallest bar — the most populated bin. Watch it drift at low n, then lock onto x ≈ 3 as n grows.
📈
Red curve = ground truth
The true N(3,1) PDF. Its peak at x = 3 is the continuous mode. This is what the histogram is trying to approximate.
🎯
Info box = convergence gap
Shows how far the orange bar's height is from the red curve's peak. Push both sliders right to shrink this gap toward 0%.

What to try — intuition builders

Fix bins at 20, drag samples from 50 → 500k. The bar heights stop jittering and the histogram shape stabilizes. The orange bar reliably centers near 3. This shows that more data reduces variance in the estimate — the histogram is a better estimator with more observations.

Fix samples at 500k, drag bins from 5 → 200. With 5 wide bins the histogram is a blocky approximation; with 200 thin bins it traces the bell almost perfectly. This shows that finer resolution reveals more shape — but only works because there is enough data to populate each thin bin reliably.

Try 50 samples + 200 bins. Most bars will be zero or near-zero with a few random spikes — completely wrong shape. This is the bias–variance tradeoff: too many bins with too little data creates a noisy, unreliable estimate even though the resolution is high.

Notice the y-axis says "density", not "count". Density = count ÷ (n × bin width). This normalization is what allows the histogram bars to align with the PDF curve — both integrate to 1 over all x. If the y-axis showed raw counts, the bars would tower far above the red line.

Distribution: N(μ=3, σ²=1)
PDF peak (mode): x = μ = 3
Peak height: 1/(σ√2π) ≈ 0.3989
Bar density: count / (n · Δx)
Area under PDF: ∫ f(x) dx = 1