Skip to main content
v2026.11,858 entries · CC-BY 4.0

Gamma Distribution Formula: Shape, Scale, Rate and Worked Example

The gamma distribution formula, mean and variance in shape-scale and shape-rate form, a checked worked example, and Excel, R and Python code.

Written and maintained by CASRAI Editorial Board

Last updated

The gamma distribution is a continuous probability distribution for positive, right-skewed values such as waiting times, durations and amounts. Its density is f(x) = xk-1 e-x/θ / (θk Γ(k)) for x ≥ 0, where k is the shape and θ is the scale (the rate is 1/θ). Its mean is kθ and its variance is kθ2. The most common source of error is mixing up scale and rate, so this page maps both forms onto Excel, R and Python.

What Is the Gamma Distribution?

The gamma distribution describes a non-negative continuous variable whose values pile up near the low end and trail off to the right. It has two parameters, a shape and a scale, and it includes the exponential and chi-square distributions as special cases. A standard use is the waiting time until the k-th event of a Poisson process (for example, the time until the fifth call arrives when calls come at a steady average rate). It is also the distribution behind the Gamma-Poisson mixture that produces the negative binomial distribution. For gamma-family priors, see Bayesian hierarchical models.

Gamma Distribution Formula (Shape, Scale, Rate)

The NIST/SEMATECH e-Handbook gives the general form with shape γ, location μ and scale β: f(x) = ((x-μ)/β)γ-1 exp(-(x-μ)/β) / (β Γ(γ)), for x ≥ μ and γ, β > 0. The case μ = 0 and β = 1 is the standard gamma distribution, f(x) = xγ-1 e-x / Γ(γ). Most software uses the two-parameter form with μ = 0, written here with k for shape and θ for scale:

f(x) = xk-1 e-x/θ / (θk Γ(k)), x ≥ 0, k > 0, θ > 0

  • x: the observed value (time, amount), which cannot be negative.
  • k (shape): controls the form of the curve. Called alpha in Excel, a in SciPy and shape in R.
  • θ (scale): stretches the curve along the x-axis, in the same units as x.
  • λ = 1/θ (rate): the same information expressed per unit of x. The alternative density is λk xk-1 e-λx / Γ(k).
  • Γ(k): the gamma function; Γ(k) = (k-1)! when k is a positive integer.
Quantity Shape and scale Shape and rate
Mean kθ k/λ
Variance kθ2 k/λ2
Mode (k ≥ 1) (k-1)θ (k-1)/λ
Skewness 2/√k 2/√k

The R documentation states the mean as a×s and the variance as a×s2 for shape a and scale s, and says that the scale defaults to 1/rate. SciPy states the same equivalence: its alpha-beta form is equivalent to the standard form with scale = 1/beta. The NIST skewness for the standard form is 2/√(shape), and the scale does not change it.

Gamma Distribution Examples: Worked Waiting-Time Example

This example is illustrative, with numbers chosen for easy arithmetic. Calls arrive at an average of 2 per minute, and we ask how long it takes until the fifth call. The waiting time T follows a gamma distribution with shape k = 5 and rate λ = 2 per minute, so the scale is θ = 1/2 = 0.5 minute.

  1. Mean: kθ = 5 × 0.5 = 2.5 minutes (check with the rate form: 5/2 = 2.5).
  2. Variance and SD: kθ2 = 5 × 0.25 = 1.25 minutes2 (rate form: 5/4 = 1.25), so SD = √1.25 = 1.118 minutes.
  3. Mode: (k-1)θ = 4 × 0.5 = 2.0 minutes. The most likely single value sits below the mean, as expected for right skew.
  4. Density at 2 minutes: f(2) = 24 e-4 / (0.55 × 24) = 16 × 0.018316 / 0.75 = 0.3907 per minute.
  5. Probability the fifth call has not arrived by 2 minutes: P(T > 2) = 0.6288, and P(T ≤ 2) = 0.3712. For an integer shape this equals the Poisson probability of at most 4 calls in 2 minutes (mean 4): e-4(1 + 4 + 8 + 10.667 + 10.667) = 0.018316 × 34.333 = 0.6288.
  6. 90th percentile: about 3.997 minutes, so nine times in ten the fifth call arrives within roughly 4 minutes.

Related cases: with k = 1 the same setup gives the exponential waiting time for the first call, and the count of calls in a fixed window is a Poisson distribution.

Interpretation

A gamma density value is not a probability. Probabilities come from areas under the curve (the cumulative distribution function), as in step 5 above.

What you see How to read it
Shape k = 1 Exponential distribution (Microsoft documents that alpha = 1 returns the exponential).
Shape n/2 with scale 2 (n a positive integer) Chi-square distribution with n degrees of freedom (Microsoft documents this relation for the cumulative form).
Positive integer shape Also called the Erlang distribution (Microsoft).
Skewness 2/√k k = 1 gives 2.0, k = 4 gives 1.0, k = 25 gives 0.4: the curve becomes more symmetric as shape grows. See left-skewed vs right-skewed data.
Mean greater than mode For k > 1 the mean is kθ and the mode is (k-1)θ, so the mean is larger by exactly θ.

Assumptions and Common Mistakes

  • Passing rate where scale is expected. Excel’s GAMMA.DIST takes beta as the scale, R’s dgamma takes rate or scale (scale = 1/rate), and SciPy takes scale. In the worked example, using 2 instead of 0.5 gives a mean of 10 minutes instead of 2.5.
  • Negative values. The distribution is defined for x ≥ 0. Excel returns #NUM! for x < 0, alpha ≤ 0 or beta ≤ 0; R gives an error if you supply both scale and rate.
  • Assuming it fits without checking. Compare a histogram of the data with the fitted density, or use a quantile-quantile plot, before relying on gamma probabilities.
  • Zero values in the data. A strictly positive distribution cannot represent exact zeros without extra handling.
  • Using it for counts. The gamma is continuous; counts belong to the Poisson or negative binomial families (see also quasi-Poisson vs negative binomial).

For a quick method-of-moments estimate, solve mean = kθ and variance = kθ2 for the parameters: k = mean2/variance and θ = variance/mean.

How to Report It (APA Example)

State the distribution, both parameters with their units and parameterization, how they were estimated, and how fit was assessed. Illustrative wording:

Waiting times until the fifth call were modeled with a gamma distribution (shape = 5, scale = 0.5 min, equivalent to a rate of 2 per min), giving a mean of 2.5 min and an SD of 1.12 min. The probability that the fifth call had not arrived by 2 min was .63.

When parameters are estimated from data, also name the method (method of moments or maximum likelihood), report the software and version, and describe the goodness-of-fit check you used.

How to Calculate It in Excel, R or Python

Each snippet reproduces the worked example (shape 5, scale 0.5, rate 2).

Excel (beta is the scale; TRUE returns the cumulative probability, FALSE the density):

=GAMMA.DIST(2, 5, 0.5, TRUE)    -> 0.3712  (P(T <= 2))
=GAMMA.DIST(2, 5, 0.5, FALSE)   -> 0.3907  (density at 2)
=1 - GAMMA.DIST(2, 5, 0.5, TRUE) -> 0.6288  (P(T > 2))

R (rate and scale are alternatives; supply only one):

pgamma(2, shape = 5, rate = 2)         # 0.3712
dgamma(2, shape = 5, scale = 0.5)      # 0.3907
qgamma(0.9, shape = 5, scale = 0.5)    # 3.997

Python (SciPy stats; scale = 1/rate):

from scipy import stats
d = stats.gamma(a=5, scale=0.5)
d.cdf(2)    # 0.3712
d.pdf(2)    # 0.3907
d.ppf(0.9)  # 3.997
d.mean(), d.var()  # 2.5, 1.25

FAQ

What is gamma distribution?

It is a two-parameter continuous distribution for non-negative, right-skewed data. The shape and scale set its form, and it contains the exponential and chi-square distributions as special cases. It models the waiting time until the k-th event in a Poisson process.

What is the gamma distribution formula?

f(x) = xk-1 e-x/θ / (θk Γ(k)) for x ≥ 0, with mean kθ and variance kθ2.

Is the second parameter scale or rate?

Both conventions exist. Rate is the reciprocal of scale. Excel and SciPy use scale; R accepts either rate or scale (scale defaults to 1/rate; supplying both is an error); many textbooks use rate.

What are some gamma distribution examples?

The waiting time until the fifth call in the example above is one; the same approach applies to any non-negative, right-skewed quantity once shape and scale are estimated; the worked example shows the full arithmetic.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Gamma Distribution Formula: Shape, Scale, Rate and Worked Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.