Topics / Chapter 5

The shape of data

To recognise which theoretical distribution our data resembles and compute probabilities from it.

You don’t have to count from scratch every time

In Chapter 4 we found probabilities by counting outcomes one by one. Real-life questions, though, tend to look alike: “How many of 20 seeds will germinate?”, “how many spots will a leaf have?”, “will a plant grow taller than 240 cm?”

Each of these questions fits a pattern that mathematicians have already studied. These patterns are called distributions. If you know which distribution your data follow, you read the probability from a formula or a ready-made table instead of counting.

What are your data like?DistributionExample question
How many successes in n trials? (two outcomes per trial)BinomialWill at least 18 of 20 seeds germinate?
How many events in a given time or area? (rare events)PoissonWill a leaf have no spots at all?
A measured continuous value (height, yield, weight)NormalWill a plant grow taller than 240 cm?
Test statisticst, χ², FIs this difference due to chance?

Data obtained by counting (nominal and ordinal scales, counts) follow discrete distributions; data obtained by measuring (interval and ratio scales) follow continuous distributions.

Binomial distribution

When is it used? When all four conditions hold:

  1. There is a fixed number of trials (nn): 20 seeds were sown.
  2. Each trial has two outcomes: germinated or not.
  3. The probability of success is the same in every trial (pp): each seed germinates with probability 85%.
  4. Trials are independent: one seed germinating doesn’t affect another.

Then the probability of exactly kk successes in nn trials is:

P(X=k)=(nk) pk q n−kP(X = k) = \binom{n}{k}\, p^k\, q^{\,n-k}

The logic is simple: pkqn−kp^k q^{n-k} is the probability of one particular ordering (e.g. the first 18 germinated, the last 2 didn’t). (nk)\binom{n}{k} counts how many different ways those 18 successes can be spread among the 20 seeds.

Example:

A coin is tossed 4 times. What is the probability of getting tails 1 or 2 times?

00.1880.375P(X = 0) = 0.06250P(X = 1) = 0.251P(X = 2) = 0.3752P(X = 3) = 0.253P(X = 4) = 0.06254Ortalama 2Number of successes (k)

Dark bars are the values included; the dashed line is the mean (2). Hover over a bar to see its probability.

Result

P(1≤X≤2)P(1 \le X \le 2) = 0.625

  1. Each trial has two outcomes (success / failure) and the success probability is the same in every trial. The probability of exactly k successes in n trials:

    P(X=k)=(nk) pk q n−k,q=1−pP(X = k) = \binom{n}{k}\, p^{k}\, q^{\,n-k}, \qquad q = 1 - p
  2. n=4,p=0.5,q=1−0.5=0.5n = 4, \quad p = 0.5, \quad q = 1 - 0.5 = 0.5
  3. P(1≤X≤2)=(41)0.51 0.53+(42)0.52 0.52P(1 \le X \le 2) = \binom{4}{1} 0.5^{1}\, 0.5^{3} + \binom{4}{2} 0.5^{2}\, 0.5^{2}
  4. =0.25+0.375=0.625= 0.25 + 0.375 = 0.625
  5. Expected (mean) number of successes n·p = 2, variance n·p·q = 1.

The Galton board: from binomial to normal

In a Galton board, each time a ball hits a peg it bounces left or right with equal probability. For a ball passing 10 rows of pegs this is a binomial experiment with 10 trials: the bin it lands in shows how many times it bounced right.

Drop a few balls, then drop 500. The shape that builds up in the bins becomes a bell. The reason is that the sum of many small, independent effects approaches a normal distribution. A plant’s height is exactly such a sum of small effects from dozens of genes, the soil, water and temperature. That is why most values measured in nature are normally distributed.

0 times right: 0 balls01 times right: 0 balls12 times right: 0 balls23 times right: 0 balls34 times right: 0 balls45 times right: 0 balls56 times right: 0 balls67 times right: 0 balls78 times right: 0 balls89 times right: 0 balls910 times right: 0 balls10

Balls dropped: 0. Bars are the observed counts, red dots the counts expected by the binomial distribution (n = 10, p = 0.5). As more balls drop, the two match up.

Poisson distribution

When is it used? When you count how many times an event happens in a given time interval or area and the event is rare: spots on a leaf, weeds per decare, breakdowns per month.

Unlike the binomial, the number of trials is not fixed. The number of “points where a spot could appear” on a leaf is practically infinite, and the chance of a spot at each is tiny. All you know is the average number of events (λ\lambda):

P(X=k)=e−λ λkk!P(X = k) = \frac{e^{-\lambda}\, \lambda^k}{k!}

The hallmark of the Poisson is that its mean and variance are equal. If the variance of count data is much larger than the mean, the events are clustering (e.g. a disease is spreading). Such data do not fit a Poisson.

Example:

On average 3 planes land at an airport every 15 minutes. What is the probability that at most 2 planes land in a given 15 minutes?

00.1120.224P(X = 0) = 0.04980P(X = 1) = 0.14941P(X = 2) = 0.2242P(X = 3) = 0.2243P(X = 4) = 0.1684P(X = 5) = 0.10085P(X = 6) = 0.05046P(X = 7) = 0.02167P(X = 8) = 0.00818P(X = 9) = 0.00279P(X = 10) = 0.000810P(X = 11) = 0.000211P(X = 12) = 0.000112P(X = 13) = 013P(X = 14) = 014P(X = 15) = 015Ortalama 3Number of events (k)

Dark bars are the values included; the dashed line is the mean (3). Hover over a bar to see its probability.

Result

P(X≤2)P(X \le 2) = 0.4232

  1. If λ events happen on average in a given time or area, the probability of exactly k events:

    P(X=k)=e−λ λkk!P(X = k) = \dfrac{e^{-\lambda}\, \lambda^{k}}{k!}
  2. λ=3,e−λ=e−3=0.049787\lambda = 3, \quad e^{-\lambda} = e^{-3} = 0.049787
  3. P(X≤2)=e−3 300!+e−3 311!+e−3 322!P(X \le 2) = \dfrac{e^{-3}\, 3^{0}}{0!} + \dfrac{e^{-3}\, 3^{1}}{1!} + \dfrac{e^{-3}\, 3^{2}}{2!}
  4. =0.0498+0.1494+0.224=0.4232= 0.0498 + 0.1494 + 0.224 = 0.4232
  5. In a Poisson distribution the mean and the variance are equal: both are λ = 3.

The normal distribution and Z scores

The normal distribution is a bell-shaped curve, symmetric around its mean, and is completely defined by two numbers: the mean (μ\mu) and the standard deviation (σ\sigma). Once you know them, this rule holds for every normal distribution:

IntervalRoughly what share of the data?
μ±1σ\mu \pm 1\sigma68%
μ±2σ\mu \pm 2\sigma95%
μ±3σ\mu \pm 3\sigma99.7%

In a maize variety with a mean height of 210 cm and a standard deviation of 15 cm, about 95% of plants are between 180 and 240 cm. If you see a 250 cm plant you know right away it is unusual.

What is a Z score for?

Every normal distribution has its own mean and unit. Instead of printing a separate table for each, values are converted to Z scores: “how many standard deviations is this value from the mean?”

z=x−μσz = \frac{x - \mu}{\sigma}

The second use of Z scores is comparing different scales. A student scored 70 in statistics (class mean 60, standard deviation 10) and 80 in genetics (mean 76, standard deviation 8). In which course did they do better relative to their class?

zstatistics=70−6010=1.0zgenetics=80−768=0.5z_{\text{statistics}} = \frac{70 - 60}{10} = 1.0 \qquad z_{\text{genetics}} = \frac{80 - 76}{8} = 0.5

The raw score is higher in genetics, but the student is much further above the class in statistics. The T score (T=50+10zT = 50 + 10z) is the same idea without negative numbers or decimals: 60 for statistics, 55 for genetics.

Example:

Plant height in a maize variety is normally distributed with mean 210 cm and standard deviation 15 cm. What is the probability that a random plant is taller than 240 cm?

-4-3-2-101234165180195210225240255z = 2Top row z, bottom row original scale

The shaded area is the probability. The total area under the curve is 1.

Result

P(X>240)P(X > 240) = 0.0228

  1. First convert the value(s) to Z scores: how many standard deviations from the mean?

  2. z=x−μσ=240−21015=2z = \dfrac{x - \mu}{\sigma} = \dfrac{240 - 210}{15} = 2
  3. Reading the table (z = 2): 0.9772 in the left-tail table, 0.4772 in the (0, z) table.

  4. The area on the right is 1 (the total area) minus the area on the left.

    P(Z>2)=1−0.9772=0.0228P(Z > 2) = 1 - 0.9772 = 0.0228
  5. As a percentage: 2.28%.

T score of the same value: 50 + 10·z = 70. T scores avoid negative numbers; they have mean 50 and standard deviation 10.

Reading the table: some textbooks’ Z tables give the area between 0 and z; others give the total area to the left of z. The two differ by 0.5. The calculator shows both values in its steps, and on the Tables page you can switch between the two formats.

t, χ² and F distributions: test statistics

These three distributions don’t describe a measurement in nature but the test statistics calculated from a sample. Their job is to answer: “If there is really no difference, how likely is it to see a test value this large by chance alone?”

For that, a significance level (α\alpha) is chosen first, usually 5% or 1%. The region at the tails of the curve with total area α\alpha is the rejection region, and its boundaries are the critical values. If your test statistic falls in the rejection region, you say “this difference can’t be explained by chance” and conclude the difference is significant.

The degrees of freedom set the shape of the curve. With small samples the t distribution is wider than the normal and has heavier tails; as the sample grows it approaches Z. Below, raise the degrees of freedom from 2 to 100 and watch the critical value approach 1.96.

Distribution

When? When the population standard deviation is unknown and the sample is small, e.g. comparing the means of two varieties.

-4-2024-2.082.08t (df = 21)

Red areas are the rejection region; their total area equals α. Change the degrees of freedom and watch how the curve’s shape changes.

Critical value

t21t_{21} ± 2.08

  1. In a two-tailed test α = 0.05 is split equally between the two tails; each tail gets 0.025.

    α2=0.052=0.025\dfrac{\alpha}{2} = \dfrac{0.05}{2} = 0.025
  2. The distribution is symmetric, so the two limits differ only in sign.

    t21=±2.08t_{21} = \pm 2.08
  3. If the test statistic falls outside these limits, H₀ is rejected.

The shape of a distribution: skewness and kurtosis

Real data are not always symmetric. In a hard exam most scores pile up at the low end, and a few high scores form a tail stretching to the right. This is a right (positively) skewed distribution, with mode < median < mean. An easy exam shows the reverse: a left (negatively) skewed distribution, mean < median < mode.

Kurtosis shows how peaked or flat a distribution is compared with the normal. The moment coefficient of kurtosis of a normal distribution is 3; above 3 the distribution is peaked, below 3 it is flat.

You can see the skewness and kurtosis of your own data in the calculator in Chapter 3.

Why does it matter? Many tests, such as the t test and analysis of variance, assume the data are normally distributed. If the data are clearly skewed, the results of these tests can mislead. Looking at the histogram and skewness of your data before testing is a good habit.