xellstorm Learning center
EN
Open the app

Gamma distribution in Excel: waiting times, totals and GAMMA.INV

Guide · Updated October 2026

In short: the total time of several waits in a row, such as three repairs one after another. More generally, a positive quantity with a tail to the right.

The gamma distribution describes a positive quantity with a right tail, and in particular the total time of several random steps in a row. A shape and a scale set it; its mean is shape × scale. In Excel, =GAMMA.INV(RAND(), shape, scale) draws from it. Three repairs in a row, each taking 2 days on average with exponential spread, take a gamma-distributed total with shape 3 and scale 2: 6.0 days on average, more than 10 days in 12.5% of cases.

What a gamma distribution is

Start from the exponential distribution, the waiting time for one random event. Wait for several such events in a row, and the total is gamma-distributed: the shape is the number of steps and the scale the mean of each. The shape need not be a whole number, which makes the gamma a flexible family for any positive, right-skewed quantity: rainfall, insurance claims, durations, demand.

How to read the chart: each line is the total time of 1, 3 or 8 waits in a row. With one wait, short times are the most common; the more waits add up, the more the total gathers around its average.

Gamma densities with scale 2 and shapes 1, 3 and 8Three gamma densities with the same scale: shape 1 is highest at zero and falls steadily (an exponential); shape 3 rises to a peak at 4.0 with a right tail; shape 8 is a wider, nearly symmetric hump around 14.0102030Shape 1Shape 3Shape 8
Gamma distributions with scale 2 (days): the total of 1, 3 or 8 exponential repairs of 2 days each on average. The more steps, the more symmetric the total.
Formulas: mean, standard deviation, peak, and from a mean and standard deviation
Gamma formulas (shape k, scale θ), worked for k = 3 and θ = 2 days
QuantityFormula and example
Meank × θ
= 6.0 days
Standard deviation√k × θ
= 3.46 days
Peak (mode)(k − 1) × θ, for k ≥ 1
= 4.0 days
From a mean and standard deviationk = (mean / sd)², θ = sd² / mean

The gamma distribution in Excel

GAMMA.INV(probability, alpha, beta) takes the shape as alpha and the scale as beta. Some textbooks write the gamma with a rate, 1 / scale, instead; Excel uses the scale, so a rate of 0.5 per day is a beta of 2. In one cell a draw is =GAMMA.INV(RAND(),D17,F17), and GAMMA.DIST(x, alpha, beta, TRUE) gives the chance of a value below x: =1-GAMMA.DIST(10, 3, 2, TRUE) is the 12.5% chance of taking more than 10 days.

Days to finish three repairs, gamma with shape 3 and scale 2Histogram of 10,000 draws by xellstorm with the exact gamma density as a line, peaking at 4.0 days with a right tail; P10 2.2, P90 10.6.05101520P10 2.2P90 10.6
Days to finish three repairs in a row, gamma with shape 3 and scale 2. Bars: 10,000 draws by xellstorm; line: the theoretical curve.
Gamma distribution in Excel, row 17 of the workbook (shape in D17, scale in F17)
CellFormulaValue
Random number u (I17)=RAND()
Draw (J17)=GAMMA.INV(I17,D17,F17)
Draw in one cell=GAMMA.INV(RAND(),D17,F17)
Mean (K17)=D17*F176.00
P10 (L17)=GAMMA.INV(0.1,D17,F17)2.20
P90 (M17)=GAMMA.INV(0.9,D17,F17)10.64
Check the numbers: exact values against 10,000 draws from Excel and from xellstorm
Days to finish three repairs, gamma: exact values and 10,000 draws each
ExactExcel, RAND()xellstorm
Mean6.005.976.00
Standard deviation3.463.503.46
P102.202.192.20
P50 (median)5.355.285.35
P9010.6410.6910.64

Excel draws with RAND(), fully at random; xellstorm spreads its draws evenly over the range (Latin Hypercube sampling), so its statistics land closer to the exact values.

Gamma or lognormal?

Both are positive and skewed to the right, and with the same mean and standard deviation they look alike in the middle. The difference is in the tail: the lognormal’s is heavier. Matched to the repairs’ mean of 6.0 and standard deviation of 3.46, a lognormal gives a 0.6% chance of more than 20 days, the gamma 0.3%. When rare, very large values matter (losses, overruns), that difference matters too: fit both to your data and compare, or choose the heavier tail to be prudent. See the lognormal distribution.

Entering a gamma distribution in xellstorm

  1. Make the cell an input and, on the Distributions step, choose Gamma. Type a (the shape) and scale; loc shifts the start away from zero, usually 0.
  2. With past values, “From data” in the side panel fits a gamma starting at zero, next to lognormal, Weibull and other shapes, and ranks them.

“Import from workbook” converts =GAMMA.INV(RAND(), alpha, beta) into a gamma input, and add-in models convert from RiskGamma, RiskErlang, VoseGamma and PsiGamma.

Questions

How do I generate gamma-distributed random numbers in Excel?

Use =GAMMA.INV(RAND(), shape, scale), for example =GAMMA.INV(RAND(), 3, 2) for a mean of 6.0. Each recalculation draws a new value.

What are the shape and scale of a gamma distribution?

The shape sets the form: 1 is an exponential distribution, larger values give a hump that grows more symmetric. The scale stretches it: the mean is shape × scale and the standard deviation √shape × scale.

What is the relationship between the gamma and the exponential distribution?

An exponential distribution is a gamma with shape 1. The sum of several independent exponential times with the same mean is a gamma with the number of times as its shape and that mean as its scale (also called an Erlang distribution).

Related

xellstorm is a browser-based Monte Carlo simulation tool for Excel models: no add-in, and the workbook never leaves your computer.