St · Statistics & Probability

How to Use the Method of Moments for a Binomial Distribution

Published By the 9to5Science editorial team

At a glance

  1. 1. Write the moments

    For a binomial variable, the mean is np and the variance is np(1 − p).

  2. 2. Match sample moments

    Set the sample mean equal to the theoretical mean; if n is unknown, also match the empirical variance.

  3. 3. Solve for parameters

    With n known, estimate p from the mean. With both unknown, solve the two moment equations.

  4. 4. Check the estimates

    Verify the estimates are feasible; a method-of-moments estimate of n need not be an integer.

Advertisement

The method of moments estimates distribution parameters by matching theoretical moments to moments calculated from the data. For a binomial random variable X∼Binomial⁡(n,p)X \sim \operatorname{Binomial}(n,p), the first two useful moments are

E[X]=np,Var⁡(X)=np(1−p).\mathbb{E}[X]=np, \qquad \operatorname{Var}(X)=np(1-p).

The calculation depends on whether the number of trials nn is known. If both nn and the success probability pp are unknown, use the sample mean and sample variance to obtain two equations.

If the number of trials is known

Suppose you observe mm independent counts x1,…,xmx_1,\ldots,x_m, each from the same binomial distribution, and nn is specified. The sample mean is

xˉ=1m∑i=1mxi.\bar{x}=\frac{1}{m}\sum_{i=1}^{m}x_i.

Match it to the theoretical mean npnp:

xˉ=np.\bar{x}=np.

Solving gives the method-of-moments estimate

p^MOM=xˉn.\hat{p}_{\mathrm{MOM}}=\frac{\bar{x}}{n}.

For example, if each observation counts successes in 1010 trials and the observed counts are 3,4,5,63, 4, 5, 6, then xˉ=4.5\bar{x}=4.5. Thus p^=4.5/10=0.45\hat p=4.5/10=0.45.

If both parameters are unknown

Now suppose both nn and pp must be estimated. Use the first two raw moments of the data, equivalently the sample mean and the empirical variance. Define the empirical variance with divisor mm:

v=1m∑i=1m(xi−xˉ)2.v=\frac{1}{m}\sum_{i=1}^{m}(x_i-\bar{x})^2.

The method-of-moments equations are

xˉ=np,v=np(1−p).\bar{x}=np, \qquad v=np(1-p).

Divide the variance equation by the mean equation (assuming xˉ>0\bar{x}>0):

vxˉ=1−p.\frac{v}{\bar{x}}=1-p.

So the estimates are

p^MOM=1−vxˉ,n^MOM=xˉp^MOM=xˉ2xˉ−v.\hat{p}_{\mathrm{MOM}}=1-\frac{v}{\bar{x}}, \qquad \hat{n}_{\mathrm{MOM}}=\frac{\bar{x}}{\hat{p}_{\mathrm{MOM}}} =\frac{\bar{x}^2}{\bar{x}-v}.

These formulas can also be derived by matching the second raw moment E[X2]=np(1−p)+(np)2\mathbb{E}[X^2]=np(1-p)+(np)^2 to m−1∑ixi2m^{-1}\sum_i x_i^2.

Worked example

Take the observed counts 1,2,2,3,41,2,2,3,4. Their mean is

xˉ=1+2+2+3+45=2.4.\bar{x}=\frac{1+2+2+3+4}{5}=2.4.

The empirical variance, using divisor 55, is

v=(1−2.4)2+(2−2.4)2+(2−2.4)2+(3−2.4)2+(4−2.4)25=1.04.v=\frac{(1-2.4)^2+(2-2.4)^2+(2-2.4)^2+(3-2.4)^2+(4-2.4)^2}{5}=1.04.

Therefore,

p^MOM=1−1.042.4≈0.567,\hat{p}_{\mathrm{MOM}}=1-\frac{1.04}{2.4}\approx 0.567,

and

n^MOM=2.422.4−1.04≈4.24.\hat{n}_{\mathrm{MOM}}=\frac{2.4^2}{2.4-1.04}\approx 4.24.

The unconstrained method-of-moments estimate for nn is not an integer. A binomial trial count must be a positive integer, so this pair is not itself a valid binomial parameter pair. If an integer estimate is required, use a method that accounts for the integer constraint, or round only after checking that the chosen nn is at least the largest observed count. Rounding is a practical adjustment, not part of the basic moment-matching calculation.

Feasibility and common mistakes

  • Using only the mean when both parameters are unknown: the equation xˉ=np\bar{x}=np identifies the product npnp, not nn and pp separately. A second moment is needed.
  • Using the unbiased sample variance without noticing the convention: the usual unbiased sample variance divides by m−1m-1. Direct method-of-moments matching uses empirical moments with divisor mm. Substituting the m−1m-1 variance gives a different estimator.
  • Ignoring the parameter bounds: a binomial model requires integer n≥1n\geq 1 and 0≤p≤10\leq p\leq 1. For positive sample mean, the formulas require 0≤v<xˉ0\leq v<\bar{x} to give a finite, nonnegative p^\hat p and positive n^\hat n. If v=xˉv=\bar{x}, the denominator for n^\hat n is zero; if v>xˉv>\bar{x}, the estimates are not feasible.
  • Treating a noninteger n^\hat n as a binomial trial count: the unconstrained moment estimate is a real number. It can be useful as a starting point, but it does not make a noninteger number of trials valid.

If all observations are zero, then xˉ=0\bar{x}=0 and the two-parameter formulas cannot determine nn; the data provide no moment-based estimate of the number of trials. In that case, additional information or a different estimation approach is needed.

References

  1. Statistical Inference, 2nd Edition — George Casella and Roger L. Berger

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.