4.3 - Fitting distributions to frequency data

4.3 - Fitting distributions to frequency data

A probability model predicts proportions, but a frequency table records counts. You will turn a prescribed distribution into expected frequencies, estimate a parameter when required, and keep complete tails when combining small classes for a chi-squared test.

Expected frequencies

If a model predicts a rare outcome, can we delete its class when nobody in the sample has that outcome? The model still assigns it a probability, so its expected count must remain somewhere in the table.

First consider a familiar binomial experiment. If each observation is the number of successes in two independent trials with success probability 1/21/2, the model probabilities for zero, one and two successes are 1/4,1/2,1/41/4,1/2,1/4. In 8080 independent observations, the corresponding expected counts are 20,40,2020,40,20.

Observed and expected frequencies

An observed frequency, OiO_i, is the number of sample observations in class ii. Its expected frequency, EiE_i, is the count predicted by the hypothesised model for a sample of the same size.

Expected does not mean guaranteed. The observed table usually differs from the predicted table because of random variation. We will later ask whether that difference is unusually large.

From probabilities to counts

For NN independent observations and exhaustive, non-overlapping classes with model probabilities pip_i,

Ei=Npi,∑iEi=N.E_i=Np_i, \qquad \sum_i E_i=N.

The count rule is not in the formula booklet: learn it. The booklet gives the binomial, geometric and Poisson probability formulae used to find the pip_i.

For a continuous model, find each class probability by integrating its density over that class, then multiply by NN. For example, f(x)=2xf(x)=2x on [0,1][0,1] gives P(X<1/2)=∫01/22x dx=1/4\mathrm P(X<1/2)=\int_0^{1/2}2x\,\mathrm dx=1/4. A sample of 8080 therefore has expected counts 2020 below 1/21/2 and 6060 at least 1/21/2.

Worked example 1: a specified binomial model

Question. A model specifies X∼B(2,1/2)X\sim\mathrm B(2,1/2). Find the expected frequencies of 0,1,20,1,2 in 8080 independent observations.

Plan. Find the three binomial probabilities, then multiply each by 8080.

P(X=0)=(1/2)2=1/4P(X=1)=2(1/2)(1/2)=1/2P(X=2)=(1/2)2=1/4.\begin{aligned} \mathrm P(X=0)&=(1/2)^2=1/4\\ \mathrm P(X=1)&=2(1/2)(1/2)=1/2\\ \mathrm P(X=2)&=(1/2)^2=1/4. \end{aligned}

Thus

(E0,E1,E2)=80(1/4,1/2,1/4)=(20,40,20).(E_0,E_1,E_2)=80(1/4,1/2,1/4)=(20,40,20).

Answer. The expected frequencies are 20,40,2020,40,20.

Check. The model has mean 2(1/2)=12(1/2)=1. The predicted table has mean (0(20)+1(40)+2(20))/80=1(0(20)+1(40)+2(20))/80=1, and its counts total 8080.

Change only the success probability. The distribution is still binomial with two trials, but symmetry between zero and two successes disappears.

Worked example 2: unequal probabilities

Question. For 8080 independent observations from the model X∼B(2,1/4)X\sim\mathrm B(2,1/4), find the expected frequencies of 0,1,20,1,2.

Plan. Use the new success probability in each binomial probability.

P(X=0)=(3/4)2=9/16P(X=1)=2(1/4)(3/4)=6/16P(X=2)=(1/4)2=1/16(E0,E1,E2)=80(9/16,6/16,1/16)=(45,30,5).\begin{aligned} \mathrm P(X=0)&=(3/4)^2=9/16\\ \mathrm P(X=1)&=2(1/4)(3/4)=6/16\\ \mathrm P(X=2)&=(1/4)^2=1/16\\ (E_0,E_1,E_2)&=80(9/16,6/16,1/16)=(45,30,5). \end{aligned}

Answer. The expected frequencies are 45,30,545,30,5.

Check. In 160160 individual Bernoulli trials the model predicts 160/4=40160/4=40 successes. The frequency table predicts 30+2(5)=4030+2(5)=40, agreeing by a different count.

Expected frequencies may be fractional: changing the sample size in the second example to 100100 gives 56.25,37.5,6.2556.25,37.5,6.25. Keep sufficient precision; rounding each expected count to an integer changes the model.

Watch out

Use the probabilities specified by the hypothesis. Replacing them by the observed proportions makes every expected count equal its observed count and removes the comparison we want to make.

Apply the same method to a different specified success probability.

Estimating permitted parameters

A hypothesis may prescribe a distribution family while leaving a parameter to be estimated from the sample.

For instance, “a binomial distribution with three trials” fixes the number of trials, but does not give the success probability. We need an estimate before we can calculate its expected frequencies. Estimate only what the question leaves unknown: a numerical parameter already specified by the hypothesis stays fixed.

Fitting from the sample mean

For exact values xx with observed frequencies fxf_x,

xˉ=∑xxfxN.\bar x=\frac{\sum_x xf_x}{N}.

For a prescribed B(n,p)\mathrm B(n,p) family with known nn, equate npnp to xˉ\bar x, giving p^=xˉ/n\hat p=\bar x/n. For a prescribed Po(λ)\mathrm{Po}(\lambda) family, equate λ\lambda to xˉ\bar x, giving λ^=xˉ\hat\lambda=\bar x.

The frequency mean and these distributions' means are in the formula booklet. The fitting step is to equate the model mean to the sample mean.

The hat identifies an estimate from this sample. The family itself must come from the hypothesis or the stated modelling instructions; matching a mean does not establish which family is suitable.

Worked example 3: fitting a binomial probability

Question. The table summarises 100100 independent observations. Fit the prescribed model B(3,p)\mathrm B(3,p) by estimating pp from the sample mean, and find its expected frequencies.

Value xx00112233
Observed frequency2424424224241010

Plan. Find the weighted mean, divide by three, then use the fitted binomial probabilities.

xˉ=0(24)+1(42)+2(24)+3(10)100=1.23p^=1.2⟹p^=0.4.\begin{aligned} \bar x&=\frac{0(24)+1(42)+2(24)+3(10)}{100}=1.2\\ 3\hat p&=1.2\quad\Longrightarrow\quad\hat p=0.4. \end{aligned}

For B(3,0.4)\mathrm B(3,0.4),

E0=100(0.6)3=21.6E1=100(31)(0.4)(0.6)2=43.2E2=100(32)(0.4)2(0.6)=28.8E3=100(0.4)3=6.4.\begin{aligned} E_0&=100(0.6)^3=21.6\\ E_1&=100\binom31(0.4)(0.6)^2=43.2\\ E_2&=100\binom32(0.4)^2(0.6)=28.8\\ E_3&=100(0.4)^3=6.4. \end{aligned}

Answer. p^=0.4\hat p=0.4, with expected frequencies 21.6,43.2,28.8,6.421.6,43.2,28.8,6.4.

Check. The expected number of successes in the table is 43.2+2(28.8)+3(6.4)=12043.2+2(28.8)+3(6.4)=120. There were 120120 observed successes in 300300 trials, so the direct success proportion is also 120/300=0.4120/300=0.4.

Keep the same observations but change the prescribed family to Poisson. Both models use the same sample mean; the mean determines a different parameter in each family.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account