Gamma Distribution Calculator

Evaluate the gamma probability density and its mean and variance from shape and scale.

Math and PercentUpdated 2026-11-202 min read
Gamma Distribution Calculator
Probability density
...
Mean...
Variance...

What it does

The gamma distribution is a flexible continuous distribution for positive values. It is used to model waiting times, rainfall, insurance losses and many skewed measurements. It includes the exponential distribution as a special case and approaches the normal distribution for large shape parameters.

This page uses the shape and scale parameterisation. The density is x to the power k minus one, times an exponential decay term, divided by the gamma function and a scale factor. An equivalent rate parameterisation replaces scale by its reciprocal, so it is important to check which form a source uses.

The mean is the shape times the scale, and the variance is the shape times the square of the scale. Those two moments make it easy to match a gamma distribution to an observed mean and variance, although more careful fitting often uses maximum likelihood.

At x equal to zero the density depends on the shape. For shape greater than one it is zero, while for shape one it equals one over the scale. The tool handles that boundary directly to avoid evaluating a logarithm of zero.

This calculator reports the density value at one point, not a probability. For a continuous distribution the probability of an interval comes from integrating the density. The tool also does not compute the cumulative distribution function or quantiles.

How to use

  1. Enter the value x at which you want the density.
  2. Enter the shape parameter, which must be positive.
  3. Enter the scale parameter, which must be positive.
  4. Read the density at x.
  5. Read the mean and variance of the distribution.
  6. Check whether your source uses scale or rate before entering parameters.

Formula

f(x) = x^(k-1) x exp(-x/theta) / (Gamma(k) x theta^k), for x > 0, k > 0 and theta > 0.
x
The value at which the density is evaluated.
k
Shape parameter, dimensionless.
theta
Scale parameter, in the same units as x.
Gamma(k)
The gamma function, a generalisation of the factorial.

Using rate beta instead of scale theta would change the exponential term to exp(-beta x) and the mean to k over beta. The tool always interprets the third input as scale. The gamma function is evaluated numerically with high accuracy for all allowed shapes.

Worked example

Example: x = 2 with shape 2 and scale 1

Defaults: x 2, shape 2 and scale 1.

  1. Gamma of 2 is 1, which is one factorial.
  2. x to the power k minus one is 2 to the power 1, which is 2.
  3. The exponential term is exp(-2) = 0.1353.
  4. Divide by Gamma(k) times theta to the k, which is 1.
  5. Density is 2 x 0.1353 = 0.270671.
  6. Mean is 2 x 1 = 2.000 and variance is 2 x 1 squared = 2.000.

Reference table

Gamma density at several x values for shape 2 and scale 1
xDensityComment
00.000000Boundary for shape above 1
10.367879Rising part
20.270671Default example
50.033690Tail

Limits

  • Reports density only, not cumulative probability or quantiles.
  • Uses shape and scale, not shape and rate.
  • Assumes a location of zero.
  • Very large shape or scale values may exceed ordinary floating point range.

Common mistakes

  • Entering rate where the tool expects scale.
  • Expecting the density value to be a probability.
  • Using a non positive shape or scale.
  • Confusing the gamma function with the gamma distribution.
  • Comparing densities across different parameterisations without conversion.

Try it yourself

Quick checks. Answers sit tucked under each question.

At x = 0 with shape 2 and scale 1, what does the tool show?

The density is 0.000000 because the shape is greater than one. Mean and variance remain 2.000 and 2.000.

What distribution results from shape equal to one?

The exponential distribution, with density decaying from one over scale at zero.

If a source gives rate 2 instead of scale, what should be entered?

Enter scale 0.5, because scale is the reciprocal of rate.

Questions

What is the gamma distribution used for?

Modelling positive skewed data such as waiting times, losses and environmental measurements.

What is the difference between shape and scale?

Shape controls the form of the density, while scale stretches or compresses it along the x axis.

What is the gamma function?

A generalisation of the factorial to real and complex arguments, appearing in the normalising constant.

Is the density a probability?

No. Probability comes from integrating the density over an interval.

How do I convert rate to scale?

Scale is one divided by rate.

What happens for large shape?

The gamma distribution becomes increasingly symmetric and approaches a normal shape.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.