St · Statistics & Probability

How to Use the Method of Moments for a Gamma Distribution

Updated 13 October 2026

At a glance

  1. 1. Choose a parameterization

    Write the gamma model using shape and scale, or convert the scale to a rate at the end.

  2. 2. Calculate sample moments

    Find the sample mean and the variance with denominator n, matching the first two raw moments.

  3. 3. Solve for the parameters

    Estimate shape as mean squared divided by variance, then estimate scale as variance divided by mean.

  4. 4. Check the result

    Verify that the fitted gamma mean and variance match the sample moments you used.

The method of moments estimates a distribution’s parameters by matching theoretical moments to moments calculated from the data. For a two-parameter gamma distribution, matching the first two moments gives estimates of the shape and scale. The main convention to watch is whether the gamma model uses a scale or a rate, and whether the sample variance uses denominator nn or n−1n-1.

Define the gamma parameterization

Use the shape–scale form X∼Gamma⁡(α,θ)X\sim\operatorname{Gamma}(\alpha,\theta), where α>0\alpha>0 is the shape and θ>0\theta>0 is the scale. Its density is

f(x)=xα−1e−x/θΓ(α)θα,x>0.f(x)=\frac{x^{\alpha-1}e^{-x/\theta}}{\Gamma(\alpha)\theta^\alpha},\qquad x>0.

The population mean and variance are

E[X]=αθ,Var⁡(X)=αθ2.\mathbb{E}[X]=\alpha\theta, \qquad \operatorname{Var}(X)=\alpha\theta^2.

Some references instead use the shape–rate form, with rate λ=1/θ\lambda=1/\theta. In that notation, the density contains e−λxe^{-\lambda x}, and the mean and variance are α/λ\alpha/\lambda and α/λ2\alpha/\lambda^2.

Derive the method-of-moments estimates

Suppose x1,…,xnx_1,\ldots,x_n are observations from the gamma distribution. Let the sample mean be

xˉ=1n∑i=1nxi.\bar{x}=\frac{1}{n}\sum_{i=1}^n x_i.

For the second moment, the method of moments uses the empirical raw moment n−1∑ixi2n^{-1}\sum_i x_i^2. Equivalently, after subtracting the squared sample mean, it uses the variance with denominator nn:

vn=1n∑i=1n(xi−xˉ)2=1n∑i=1nxi2−xˉ2.v_n=\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^2 =\frac{1}{n}\sum_{i=1}^n x_i^2-\bar{x}^2.

Match these quantities to the gamma mean and variance:

xˉ=αθ,vn=αθ2.\bar{x}=\alpha\theta, \qquad v_n=\alpha\theta^2.

Dividing the variance equation by the mean equation gives θ=vn/xˉ\theta=v_n/\bar{x}. Substituting this into the mean equation gives the estimates

α^MOM=xˉ 2vn,θ^MOM=vnxˉ.\hat{\alpha}_{\mathrm{MOM}}=\frac{\bar{x}^{\,2}}{v_n}, \qquad \hat{\theta}_{\mathrm{MOM}}=\frac{v_n}{\bar{x}}.

For the shape–rate parameterization, take the reciprocal of the scale estimate:

λ^MOM=xˉvn.\hat{\lambda}_{\mathrm{MOM}}=\frac{\bar{x}}{v_n}.

These formulas require a positive sample mean and positive sample variance. If all observations are identical, then vn=0v_n=0 and the formulas do not give a finite, positive gamma shape and scale.

Worked example

Suppose the observed data are 2,4,62,4,6. The sample mean is

xˉ=2+4+63=4.\bar{x}=\frac{2+4+6}{3}=4.

The variance using denominator n=3n=3 is

vn=(2−4)2+(4−4)2+(6−4)23=83.v_n=\frac{(2-4)^2+(4-4)^2+(6-4)^2}{3} =\frac{8}{3}.

Therefore,

α^MOM=428/3=6,θ^MOM=8/34=23.\hat{\alpha}_{\mathrm{MOM}}=\frac{4^2}{8/3}=6, \qquad \hat{\theta}_{\mathrm{MOM}}=\frac{8/3}{4}=\frac{2}{3}.

The fitted model is Gamma⁡(6,2/3)\operatorname{Gamma}(6,2/3) in the shape–scale convention. In the shape–rate convention, it is Gamma⁡(6,3/2)\operatorname{Gamma}(6,3/2), since the rate is the reciprocal of the scale. Checking the fitted moments confirms the result: the mean is 6(2/3)=46(2/3)=4, and the variance is 6(2/3)2=8/36(2/3)^2=8/3.

Which sample variance should you use?

The strict method-of-moments calculation matches the first two empirical raw moments, so it uses vnv_n, with denominator nn. Do not automatically substitute the usual unbiased sample variance

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

Some applied discussions or software may use s2s^2 when matching a theoretical mean and variance. That convention gives xˉ 2/s2\bar{x}^{\,2}/s^2 for shape and s2/xˉs^2/\bar{x} for scale; it is a different finite-sample calculation. Since s2=nn−1vns^2=\frac{n}{n-1}v_n, its estimates differ from the raw-moment method. Check which convention a problem or implementation specifies.

Common mistakes

  • Mixing up scale and rate: The rate is the reciprocal of the scale. A scale estimate of 2/32/3 corresponds to a rate estimate of 3/23/2, not 2/32/3.
  • Using the wrong variance denominator: For the usual raw-moment method, use denominator nn. Using n−1n-1 changes the estimates.
  • Treating the gamma shape as the mean: The mean is the product αθ\alpha\theta; the shape alone is not generally the mean.
  • Ignoring the data assumptions: A gamma random variable is positive. If observations include zeros because of censoring, rounding, or a separate probability mass at zero, the ordinary two-parameter gamma model may not describe the data appropriately.

References

  1. Statistical Inference, Second Edition — George Casella and Roger L. Berger
  2. Continuous Univariate Distributions, Volume 1, Second Edition — Norman L. Johnson, Samuel Kotz, and N. Balakrishnan

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