Machine Learning & Signals Learning
6 Statistical Plots
The three plots of this chapter are also the summaries named in step 5 of the Monte-Carlo recipe of Sec. 5.4. There they are applied to the \(k\) stored values of a simulated statistic rather than to raw measurements, but nothing below depends on where the numbers came from.
6.1 Boxplot
6.1.1 Preliminaries
Quartiles: Given the order statistics \(x_{(1)}\le \cdots \le x_{(n)}\), the three quartiles divide the sorted data into four equal parts:
-
• \(Q_1\) (first quartile, 25th percentile) — the median of the lower half of the data.
-
• \(Q_2\) (second quartile, 50th percentile) — the median of the entire data set.
-
• \(Q_3\) (third quartile, 75th percentile) — the median of the upper half of the data.
Equivalently, approximately 25% of the observations fall below \(Q_1\), and another 25% up to \(Q_3\).
Interquartile range: The interquartile range (IQR) measures the spread of the central 50% of the data,
\(\seteqnumber{0}{6.}{0}\)\begin{equation} \mathrm {IQR} = Q_3 - Q_1. \end{equation}
Outlier: An outlier is any observation that falls outside the interval
\[ \bigl [Q_1 - 1.5\,\mathrm {IQR},\;\; Q_3 + 1.5\,\mathrm {IQR}\bigr ]. \]
Such points are considered unusually far from the bulk of the data and may indicate measurement errors, rare events, or heavy-tailed behavior.
The coefficient 1.5 was proposed empirically by the statistician John Tukey in the 1970s.
6.1.2 Plot
A boxplot (box-and-whisker plot) summarizes a data set using five statistics:
-
1. Minimum non-outlier value.
-
2. First quartile (\(Q_1\)).
-
3. Median (\(Q_2\)).
-
4. Third quartile (\(Q_3\)).
-
5. Maximum non-outlier value.
The boxplot is drawn as follows:
-
• A box spans from \(Q_1\) to \(Q_3\), with a line at the median \(Q_2\).
-
• Whiskers extend from the box to the most extreme data points that lie within
\[ \bigl [Q_1 - 1.5\,\mathrm {IQR},\;\; Q_3 + 1.5\,\mathrm {IQR}\bigr ]. \]
-
• Any observation outside the whisker range is marked individually as a potential outlier.
An illustration of a boxplot with its components is shown in Fig. 6.1.
Interpretation
-
• The box width (IQR) reflects variability — a wide box indicates high spread.
-
• The median line position within the box reveals skewness: if the median is closer to \(Q_1\), the distribution is right-skewed; if closer to \(Q_3\), left-skewed.
-
• Whisker lengths indicate the range of typical observations.
-
• Individual points beyond the whiskers flag potential outliers that may warrant further investigation.
Unlike histograms, boxplots do not show the shape of the distribution (e.g., multimodality). They are most useful for comparing distributions across groups side by side.
-
Example 6.1 (Boxplot by hand): Eleven measurements, already sorted, are
\[ 3,\ 7,\ 8,\ 12,\ 13,\ 14,\ 18,\ 21,\ 22,\ 27,\ 52 . \]
-
(a) Find \(Q_1\), \(Q_2\), \(Q_3\) and the IQR.
-
(b) Find the outlier fences and list any outliers.
-
(c) Where do the whiskers end?
-
(d) Sketch the boxplot, and say in one sentence what its shape reports about the data.
-
Solution: Quartiles. With \(n=11\) odd, \(Q_2\) is the sixth order statistic, and each half is taken without it, leaving five values on each side.
\(\seteqnumber{0}{6.}{1}\)\begin{align*} Q_2 &= x_{(6)} = 14\\ Q_1 &= \text {median of }\left \{3,7,8,12,13\right \} = 8\\ Q_3 &= \text {median of }\left \{18,21,22,27,52\right \} = 22\\ \mathrm {IQR} &= Q_3-Q_1 = 22-8 = 14 \end{align*} Software differs in how it interpolates quartiles, so a plotting routine may return values a fraction away from these; the reading of the plot does not change.
Fences and outliers.
\(\seteqnumber{0}{6.}{1}\)\begin{align*} 1.5\,\mathrm {IQR} &= 21\\ \left [Q_1-1.5\,\mathrm {IQR},\ Q_3+1.5\,\mathrm {IQR}\right ] &= \left [8-21,\ 22+21\right ] = \left [-13,\ 43\right ] \end{align*} One observation, \(52\), falls outside and is marked as an outlier. Nothing falls below \(-13\), since that fence lies far outside the range of the data.
Whiskers. The whiskers reach the most extreme observations that are not outliers, so they end at \(3\) and at \(27\), not at \(-13\) and \(43\), and not at \(52\). The five statistics drawn are therefore
\(\seteqnumber{0}{6.}{1}\)\begin{equation*} 3,\quad 8,\quad 14,\quad 22,\quad 27, \end{equation*}
with \(52\) plotted as a separate marker (Fig. 6.2).
Figure 6.2: The boxplot of the eleven measurements. The axis reaches down to the lower fence at \(-13\), far outside the data, while the upper fence at \(43\) cuts through it: that asymmetry is why exactly one observation is flagged. The whiskers stop at \(3\) and \(27\), the most extreme values inside the fences, not at the fences themselves.Reading the shape. \(Q_2-Q_1 = 6\) against \(Q_3-Q_2 = 8\), and the upper whisker is longer than the lower one, so the data lean slightly to the right. The single far point at \(52\) is what a boxplot is built to expose, and it is the value worth checking before anything else is computed from this sample.
-
6.2 Histogram
6.2.1 Discrete Values
count type
Consider an experiment with:
-
• \(k\) possible distinct outcomes \(x_{1},x_{2},\ldots ,x_{k}\), where \(k\) is relatively small.
-
• A total of \(N\) trials.
-
• Recorded results:
-
– \(n_{1}\) occurrences of \(x_{1}\),
-
– \(n_{2}\) occurrences of \(x_{2}\),
-
– \(\ldots \) and so on,
with \(\sum _{i} n_{i}=N\).
-
The highest bar in a count histogram identifies the mode of the sample. A graphical representation of the outcomes is shown in Fig. 6.3(a).
probability type
Approximation to the PDF: The probability of a particular outcome is approximated by the ratio of its count to the total number of trials,
\(\seteqnumber{0}{6.}{1}\)\begin{equation} \label {eq:rand1:numeric_PDF_discr} p_X[x_i]\approx \frac {n_i}{N}, \qquad i = 1,\ldots ,k. \end{equation}
Naturally, the approximation improves as \(N \to \infty \).
A graphical example of this histogram type is shown in Fig. 6.3(b).
6.2.2 Continuous Values
When the number of possible outcomes, \(k\), is large (on the order of hundreds or more, or continuous values) two main difficulties arise:
-
• Presenting the results in a compact, readable form.
-
• Some outcome categories contain very few observations because their probabilities are small.
A practical way to display the data is:
-
1. Record the extreme values, \(x_{\max }\) and \(x_{\min }\).
-
2. Partition the interval \(\bigl [x_{\min },x_{\max }\bigr ]\) into \(k\) equal-width bins of size \(\Delta x\).
-
3. Mark each bin by its midpoint
\(\seteqnumber{0}{6.}{2}\)\begin{equation} \label {eq:rand1:mid_point} \tilde {x}_{i}=x_{\min }+\Bigl (i-\frac 12\Bigr )\,\Delta x, \qquad i=1,\dots ,k, \end{equation}
-
4. Let \(n_{1}\) be the count in the first bin, \(n_{2}\) the count in the second, and so on.
-
5. Use the pairs \(\left (\tilde {x}_{i},n_{i}\right )\) for count or probability type histograms.
An example of a count histogram for a large data set is shown in Fig. 6.4.
6.2.3 PDF Approximation of Continuous Random Variable (*)
In addition to the binning method described above, there is a third histogram type that directly approximates the PDF of a continuous random variable.
Approximation to the PDF of a continuous random variable via histogram:
\(\seteqnumber{0}{6.}{3}\)\begin{equation} \label {eq:stat:hist_pdf} f_X(x_i) \approx \frac {n_i}{N}\cdot \frac {1}{\Delta x}, \quad i = 1,\ldots ,k \end{equation}
Note the normalization factor \(1/\Delta x\), which distinguishes this from the discrete case in (6.2).
A graphical example of this histogram type is shown in Fig. 6.5.
Derivation
Based on the principle
\(\seteqnumber{0}{6.}{4}\)\begin{equation} \Pr (a<X\le b) = \int _{a}^{b}f_X(x)\,dx, \end{equation}
the probability of falling within a bin of width \(\Delta x\) centered at \(x_0\) can be approximated as
\(\seteqnumber{0}{6.}{5}\)\begin{align} \Pr \!\Bigl (x_0-\tfrac {\Delta x}{2} < X \le x_0 +\tfrac {\Delta x}{2}\Bigr ) &= \int _{\Delta x}f_X(x)\,dx \approx f_X(x_0)\,\Delta x. \end{align} An illustration of this principle is shown in Fig. 6.6.
Rearranging,
\(\seteqnumber{0}{6.}{6}\)\begin{equation} \label {eq:stat:histogram_deriv} f_X(x_0) \approx \Pr \!\Bigl (x_0-\tfrac {\Delta x}{2} < X \le x_0 +\tfrac {\Delta x}{2}\Bigr )\cdot \frac {1}{\Delta x}. \end{equation}
The probability of falling in bin \(i\) (centered at \(\tilde {x}_i\)) is approximated by the relative frequency,
\(\seteqnumber{0}{6.}{7}\)\begin{equation} \label {eq:stat:hist_prob} \Pr \!\Bigl (\tilde {x}_i-\tfrac {\Delta x}{2} < X \le \tilde {x}_i +\tfrac {\Delta x}{2}\Bigr ) \approx \frac {n_i}{N}, \quad i = 1,\ldots ,k. \end{equation}
Substituting (6.8) into (6.7) yields the PDF approximation formula in (6.4).
-
Example 6.2 (Computing a PDF histogram): Given the experimental outcomes
\[ \left [16,\,98,\,96,\,49,\,81,\,14,\,43,\,92,\,80,\,96\right ], \]
display the PDF using a histogram with \(k=3\) bins.
-
\(\seteqnumber{0}{6.}{8}\)
\begin{align*} N &= 10\\ x_{\min } &= 14,\quad x_{\max } = 98\\ x_{\max } &= x_{\min } + k\,\Delta x = 98\quad \Rightarrow \Delta x = \frac {x_{\max }-x_{\min }}{k} = \frac {84}{3} = 28 \end{align*} Counts per bin:
\(\seteqnumber{0}{6.}{8}\)\begin{align*} n_1 &= 2, &\leftarrow \lbrace 14,16\rbrace &\in [x_{\min },\;x_{\min } + \Delta x] &&= [14,42]\\ n_2 &= 2, &\leftarrow \lbrace 43, 49\rbrace &\in (x_{\min } + \Delta x,\;x_{\min } + 2\Delta x] &&= (42,70]\\ n_3 &= 6, &\leftarrow \lbrace 80,81,92,96,96,98\rbrace &\in (x_{\max } - \Delta x,\;x_{\max }] &&= (70,98] \end{align*} where \(n_3 = 10 - n_1 - n_2\). Bin midpoints:
\(\seteqnumber{0}{6.}{8}\)\begin{align*} \tilde {x}_1 &= x_{\min } + \tfrac {\Delta x}{2} = 28\\ \tilde {x}_2 &= x_{\min } + \Delta x + \tfrac {\Delta x}{2} = 56\\ \tilde {x}_3 &= x_{\max } - \tfrac {\Delta x}{2} = 84 \end{align*} The PDF approximation is therefore
\[ f_X(\tilde {x}_i) \approx \frac {n_i}{N\cdot \Delta x} = n_i \cdot \frac {1}{10\cdot 28}. \]
-
\(\seteqnumber{0}{6.}{8}\)
Summary
Three ways to display experimental results as a histogram:
-
• count: plot \(n_i\) — the raw bin counts.
-
• probability: plot \(n_i/N\) — the relative frequency per bin.
-
• pdf (or density): plot \(\dfrac {n_i}{N\,\Delta x}\) — the estimated probability density.
-
Example 6.3 (Why the pdf histogram divides by the bin width): A histogram of \(N\) samples has \(k\) bins of equal width \(\Delta x\), with counts \(n_1,\dots ,n_k\).
-
(a) Compute the total area under the bars for each of the three types, count, probability and pdf. Which one is normalized the way a PDF must be?
-
(b) The bins are now merged in pairs, so that the width becomes \(2\Delta x\). What happens to the height of a bar in each of the three types?
-
-
(a) Each bar has width \(\Delta x\), so the area is the height times \(\Delta x\), summed over the bins,
\(\seteqnumber{0}{6.}{8}\)\begin{align*} \texttt {count}:\quad &\sum _{i=1}^{k} n_i\,\Delta x = N\,\Delta x\\ \texttt {probability}:\quad &\sum _{i=1}^{k} \frac {n_i}{N}\,\Delta x = \Delta x\\ \texttt {pdf}:\quad &\sum _{i=1}^{k} \frac {n_i}{N\,\Delta x}\,\Delta x = \frac {1}{N}\sum _{i=1}^{k} n_i = 1 \end{align*} Only the third is unity, and it is unity for any \(\Delta x\) and any \(N\). The other two carry the units of the experiment: the count area grows with the sample size, and the probability area grows with the bin width. Dividing by \(\Delta x\) in (6.4) is therefore not a cosmetic scaling but the step that turns a tally into a density.
-
(b) Merging bins \(i\) and \(i+1\) gives a new count \(n' = n_i + n_{i+1}\) over a width \(2\Delta x\),
\(\seteqnumber{0}{6.}{8}\)\begin{align*} \texttt {count}:\quad & n' = n_i+n_{i+1} &&\text {roughly doubles}\\ \texttt {probability}:\quad & \frac {n'}{N} = \frac {n_i}{N}+\frac {n_{i+1}}{N} &&\text {roughly doubles}\\ \texttt {pdf}:\quad & \frac {n'}{N\cdot 2\Delta x} = \frac {1}{2}\left (\frac {n_i}{N\Delta x} + \frac {n_{i+1}}{N\Delta x}\right ) &&\text {the \textit {average} of the two} \end{align*} The first two bars move with the bookkeeping; the third stays on the same scale and becomes a coarser reading of the same curve. This is the derivation (6.7) seen from the other side: the density is what survives the choice of \(\Delta x\), which is why only the pdf type can be overlaid on a theoretical \(f_X(x)\) without rescaling.
-
-
6.2.4 Bin Count Variance
Every bin count \(n_i\) of the previous subsections is itself a random quantity. Repeating the same experiment redraws the whole picture, in the same way that a repeated experiment redrew the sample mean in Sec. 5.1.
Each of the \(N\) observations either falls into bin \(i\), with probability \(p_i\), or does not, independently of all the other observations. The count \(n_i\) therefore counts the successes of \(N\) independent yes/no trials, which is a binomial random variable,
\(\seteqnumber{0}{6.}{8}\)\begin{equation} \label {eq-hist-binomial} n_i \sim \mathrm {Bin}(N,p_i),\qquad \E [n_i] = Np_i,\qquad \Var [n_i] = Np_i(1-p_i), \end{equation}
where \(p_i\) is the true probability of the bin, the very quantity that the ratio \(n_i/N\) of (6.2) or (6.8) target to estimate.
count type
A bar sits at its expected height \(Np_i\) up to a fluctuation of
\(\seteqnumber{0}{6.}{9}\)\begin{equation} \label {eq-hist-bin-std} \sigma _{n_i} = \sqrt {Np_i(1-p_i)} , \end{equation}
which is the std of an estimate, exactly as the standard error of Sec. 5.2.1 was. Fig. 6.7 shows both: thirty repetitions of one experiment, and the band (6.10) they are supposed to stay in.
Since \(p_i\) is smallest in the tails, the tail bars are always the least reliable part of a histogram. In Fig. 6.7 the central bar is \(79\pm 8\) (\(10\%\)), while the bar at \(x\approx 2.4\) is \(4.6\pm 2.1\) (\(46\%\)) and nearly doubles or vanishes from one repetition to the next. A lone bump out there is not evidence of a second mode of a multimodal distribution, and the same caution applies to any bin holding a handful of observations.
In practice \(p_i\) is unknown and is replaced by the observed ratio \(n_i/N\), in the same way that \(\sigma \) was replaced by \(s_x\) in (5.16),
\(\seteqnumber{0}{6.}{10}\)\begin{equation} \label {eq-hist-bin-std-est} \widehat {\sigma }_{n_i} = \sqrt {n_i\left (1-\frac {n_i}{N}\right )} \approx \sqrt {n_i} , \end{equation}
where the last step holds when a single bin holds a small share of the data, i.e. when \(k\) is large.
The square-root rule
A bar of height \(n_i\) carries an error bar of about \(\sqrt {n_i}\), so its relative accuracy is
\(\seteqnumber{0}{6.}{11}\)\begin{equation} \label {eq-hist-bin-rel} \frac {\sigma _{n_i}}{n_i}\approx \frac {1}{\sqrt {n_i}} . \end{equation}
It is set by the count of that bar alone, and not by the total \(N\), by the bin width, or by the histogram type plotted.
Representative values are listed in Table 6.1. A bar built on \(9\) observations is worth a third of itself, and three digits of a bar are never available: they would require \(10^6\) observations inside that single bin.
| \(n_i\) | Relative error, \(1/\sqrt {n_i}\) |
| \(4\) | \(50\%\) |
| \(25\) | \(20\%\) |
| \(100\) | \(10\%\) |
| \(400\) | \(5\%\) |
| \(10^{4}\) | \(1\%\) |
-
Example 6.4 (Reliability of the bars of a histogram): Continue the \(N=10\) outcomes of the previous example, whose \(k=3\) bins hold \(n_1=2\), \(n_2=2\) and \(n_3=6\) observations. How reliable are these three bars?
-
Solution: With \(p_i\) replaced by the observed ratio \(n_i/N\), Eq. (6.10) gives
\(\seteqnumber{0}{6.}{12}\)\begin{align*} \sigma _{n_1} = \sigma _{n_2} &= \sqrt {10\cdot 0.2\cdot 0.8} = 1.26 \quad (63\%)\\ \sigma _{n_3} &= \sqrt {10\cdot 0.6\cdot 0.4} = 1.55 \quad (26\%) \end{align*} Reading the bars. The tallest bar is \(6\pm 1.5\) and the two others are \(2\pm 1.3\) each. The first two bins are indistinguishable from one another, so their order carries no information: a repetition of the experiment can easily exchange them, and can just as easily empty one of them.
Sizing the experiment. Inverting (6.12) for a target relative error of \(10\%\) on the third bin requires \(n_3 = 1/0.1^2 = 100\) observations inside that bin, that is \(N = n_3/p_3 \approx 100/0.6 \approx 167\) observations in total. One reliable digit on the tallest bar costs \(\times 17\) the present data.
-
-
Example 6.5 (How much to trust a bar): A histogram is built from \(N=400\) samples. One bin holds \(n_i = 16\) of them.
-
(a) Using (6.10), compute the std of this bin count, taking \(p_i\) from the observed ratio.
-
(b) Compare it with the approximation (6.11), and say when that approximation is safe.
-
(c) What is the relative error (6.12) of this bar?
-
(d) How many samples \(N\) would be needed to bring that relative error down to \(5\%\), with the bin width and the underlying distribution unchanged?
-
-
(a) The count in a bin is binomial (6.9), with \(p_i\) estimated by \(n_i/N = 16/400 = 0.04\),
\(\seteqnumber{0}{6.}{12}\)\begin{equation*} \sigma _{n_i} = \sqrt {Np_i(1-p_i)} = \sqrt {400\cdot 0.04\cdot 0.96} = \sqrt {15.36} \approx 3.92 . \end{equation*}
-
(b) The approximation (6.11) drops the factor \((1-p_i)\),
\(\seteqnumber{0}{6.}{12}\)\begin{equation*} \sigma _{n_i} \approx \sqrt {n_i} = \sqrt {16} = 4 , \end{equation*}
within \(2\%\) of the exact value. The neglected factor is \(\sqrt {1-p_i}\), so the approximation is safe whenever a bin holds a small share of the data, say \(p_i \lesssim 0.1\). That is the normal case: a histogram with any resolution at all spreads the samples over many bins.
-
(c)
\(\seteqnumber{0}{6.}{12}\)\begin{equation*} \frac {\sigma _{n_i}}{n_i} \approx \frac {1}{\sqrt {n_i}} = \frac {1}{4} = 25\% . \end{equation*}
A bar drawn at \(16\) really means \(16\pm 4\). Two neighboring bars differing by a quarter of their height are not distinguishable.
-
(d) The relative error depends on the count in the bin alone,
\(\seteqnumber{0}{6.}{12}\)\begin{equation*} \frac {1}{\sqrt {n_i}} \le 0.05 \quad \Longrightarrow \quad n_i \ge 400 . \end{equation*}
With the bin width and the distribution unchanged, \(p_i\) stays at \(0.04\), so
\(\seteqnumber{0}{6.}{12}\)\begin{equation*} N = \frac {n_i}{p_i} = \frac {400}{0.04} = 10^{4} , \end{equation*}
twenty-five times the original sample for five times the accuracy, the usual \(1/\sqrt {N}\) toll.
-
-
Choice of the Bin Width
Accuracy is bought with counts per bin, and the counts per bin are controlled by \(\Delta x\): a bin twice as wide collects about twice as many observations. Halving \(\Delta x\), i.e. doubling \(k\), therefore halves every \(n_i\) and multiplies the relative error (6.12) by \(\sqrt 2\). At a fixed \(N\) the two desirable properties work against each other:
-
• Wide bins (small \(k\)): reliable bars, but the shape of the distribution is resolved coarsely.
-
• Narrow bins (large \(k\)): fine resolution, but bars so noisy that part of the shape they show is a counting artifact.
A practical target is to keep the bins that carry the interpretation above a few tens of counts, \(n_i\gtrsim 25\) in Table 6.1, and to read no shape at all from the bins below that.
Summary
The three display types of the summary above are the same count multiplied by a fixed constant, so they carry the same error in different units:
-
• count: \(n_i\), with std \(\sigma _{n_i}\).
-
• probability: \(\dfrac {n_i}{N}\), with std \(\dfrac {\sigma _{n_i}}{N} = \sqrt {\dfrac {p_i(1-p_i)}{N}}\).
-
• pdf: \(\dfrac {n_i}{N\,\Delta x}\), with std \(\dfrac {\sigma _{n_i}}{N\,\Delta x}\).
Dividing the height by \(N\) or by \(N\,\Delta x\) divides its fluctuation by the same constant, so the relative error stays \(1/\sqrt {n_i}\) in all three. The normalization changes the units of the plot, never the reliability of a bar.
6.3 Violin Plot
A violin plot extends the boxplot by adding a (smoothed1) histogram of the data on each side. A median line is typically drawn inside.
Fig. 6.8 compares the two representations for the same bimodal data set: the boxplot gives no indication of two groups, whereas the violin plot clearly shows two bulges.
1 This smoothing is termed kernel density estimation (KDE). It is a special case of kernel smoothing in Sec. 10.5. The discussion of this technique is beyond the scope of this chapter.
6.4 Exercises
6.1 (probability computation) Given the PDF of a random variable \(X\), of the form
\[f_X\left (x\right )=\frac {1}{2}e^{2x};\ \ -\infty <x<\ln (a)\]
Find:
-
(a) the value of the coefficient \(a\)
-
(b) \(F_X(x)\)
-
(c) \(\E [X]\)
-
(d) \(\E [X^2]\)
-
(e) \(\Pr (X<0)\)
-
(f ) the median
-
(g) A histogram (Fig. 6.9) is given for 100,000 random values distributed according to \(X\). The \(x\)-axis uses bins of width \(\Delta x=1\).
For the histogram, compute the following values:
-
(1) What is the theoretical number of values in the interval between 0 and 1 in the histogram, out of the total 100,000 values (type count)?
-
(2) What is the probability of values in the interval between 0 and 1, in the histogram (type probability)?
-
(3) What is the theoretical value of \(\hat {f}_X(0.5)\) for the histogram (type pdf)?
-
Reminder:
\[ \lim \limits _{x\rightarrow -\infty } x^ne^x \rightarrow 0, \quad e^{\ln (a)} =a, \quad \ln (2)\approx 0.69314718 \]
6.2 (histogram) A random experiment was performed in which \(N=500\) values of a continuous random variable \(X\) were sampled. To analyze the results, the range of values was divided into bins of uniform width \(\Delta x = 4\). Focus on a specific bin defined by the interval \([10, 14]\). In this bin, \(n_i = 80\) outcomes out of the experiment were counted.
-
(a) Compute the bar height (\(y\)-axis) for the given bin \([10, 14]\) in each of the following three histogram types:
-
(1) a count histogram.
-
(2) a probability histogram (relative frequency).
-
(3) a pdf histogram (density).
-
-
(b) For a pdf histogram, what is the area of the bar in the above bin? What is the probabilistic meaning of this area?
-
(c) It is given that in another bin, \([20, 24]\), the bar height in the pdf histogram is \(0.03\). How many outcomes (\(n_j\)) fell in this bin?
6.3 (simulation: bin-width sweep) Investigate by simulation how the bin width trades resolution against reliability.
Draw \(N=1000\) samples from \(\mathcal {N}(0,1)\) (randn) and plot pdf histograms of the same data with \(k = 5\), \(20\) and \(100\) bins, overlaying the true \(f_X(x)\) in each case.
-
(a) For each \(k\), report the typical bin count \(n_i\) near the center of the distribution and the predicted relative error \(1/\sqrt {n_i}\).
-
(b) Which of the three reproduces the true density best, and which two fail, for opposite reasons?
-
(c) Which \(k\) keeps every central bin above the working rule \(n_i\gtrsim 25\)?
Compare the observed scatter of the bars with Fig. 6.7 and Table 6.1.