Calculator

Gamma Distribution

Calculate density, cumulative probabilities and quantiles of the gamma distribution with shape and scale.

Settings

Calculator focused on this distribution.

Result and visualization

Calculate PDF/PMF, CDF and percentiles instantly.

Result pending…

Explanation

The gamma distribution is a continuous distribution defined for positive values that generalizes the exponential distribution. While the exponential models the time until the first event of a Poisson process, the gamma with shape parameter k models the time until k consecutive events occur. This makes it ideal for cumulative waiting times, insurance claim severities and durations of processes with multiple stages. When k is a positive integer it is called the Erlang distribution. Its mean is k·θ and its variance is k·θ², so increasing θ shifts the distribution to the right and increasing k reduces the skewness, bringing it closer to a normal distribution via the central limit theorem.

Formula

\( f(x;k,\theta)=\frac{x^{k-1}e^{-x/\theta}}{\Gamma(k)\theta^k},\quad x>0 \)

Parameters

  • k: shape parameter (k > 0). Integer values correspond to the Erlang distribution.
  • θ (theta): scale parameter (θ > 0). Determines the spread and the mean together with k.
  • x: positive value at which the distribution is evaluated (x > 0).

Worked example

Situation: The repair time of an industrial machine is modeled with a Gamma distribution with shape parameter \(\alpha = 3\) and scale parameter \(\beta = 2\) hours. This is equivalent to assuming that the repair requires completing 3 independent stages, each with a mean duration of 2 hours.

Question 1: What is the mean repair time and what is the probability of finishing in 8 hours or less, \(P(X \leq 8)\)?

Solution: The mean of Gamma(\(\alpha, \beta\)) is: \[ E[X] = \alpha \cdot \beta = 3 \times 2 = 6 \text{ hours} \] To calculate \(P(X \leq 8)\) we use the regularized incomplete gamma function \(P(X \leq 8) = \Gamma_{\text{reg}}(3;\, 8/2) = \Gamma_{\text{reg}}(3;\, 4)\). Evaluating numerically: \[ P(X \leq 8) = 1 - e^{-4}(1 + 4 + 8) \approx 0.7619 \] There is approximately a 76.19% probability of completing the repair in 8 hours or less.

Question 2: What is the variance and what does it mean for the uncertainty of the repair time?

Solution: The variance of the Gamma is: \[ \text{Var}(X) = \alpha \cdot \beta^2 = 3 \times 4 = 12 \text{ h}^2 \implies \sigma = \sqrt{12} \approx 3.46 \text{ h} \] The standard deviation of 3.46 hours represents more than 57% of the mean, which reflects considerable variability in repair times.

Interpretation: With a mean of 6 hours and \(P(X \leq 8) \approx 0.762\), 23.8% of repairs take longer than 8 hours. If the service-level goal is to complete 90% of repairs on time, the 90th percentile of the Gamma(3, 2) can be used as the guaranteed maximum turnaround time.

How to interpret the result

The calculator offers three types of output. The PDF, \( f(x) \), gives the probability density at point \( x \): it indicates how concentrated the distribution is in that area. With \( k = 1 \) the curve is decreasing (identical to the exponential); with \( k > 1 \) a peak appears (the mode is \( (k-1)\theta \)) and the curve takes on a skewed bell shape that shifts to the right as \( k \) increases. In the chart, the green area represents the cumulative probability of the selected range; the horizontal axis starts at zero (the gamma distribution only takes positive values).

The CDF, \( P(X \leq x) \), accumulates the probability from zero up to \( x \): it represents the probability that the variable (for example, a cumulative waiting time) is less than or equal to \( x \). If \( P(X \leq 1) = 0.78 \) with \( k = 3 \) and \( \theta = 0.25 \) hours, it means that 78% of processes complete their 3 stages in less than 1 hour. The right tail \( P(X > x) \) measures the probability that the process takes longer than \( x \) units, useful for sizing buffers and service times.

The percentile or quantile result returns the value \( x \) such that \( P(X \leq x) = p \). The 90th percentile indicates the time that only 10% of processes exceed, which allows setting service thresholds with a given coverage. In reliability engineering, the 10th percentile (B10) is the time before which 10% of components fail, a common standard for evaluating system durability.

Frequently asked questions

  • What do the shape and scale parameters mean? The shape controls the profile of the curve (low values give strong skew; high values make it close to normal) and the scale stretches the horizontal axis. The mean equals shape × scale.
  • How does it relate to the exponential and the chi-square? Both are special cases: the exponential is a gamma with shape 1, and the chi-square with k degrees of freedom is a gamma with shape k/2 and scale 2.
  • What is it used for in practice? For accumulated waiting times (time until the k-th event of a Poisson process), reliability, rainfall, insurance claim costs, and as a conjugate prior in Bayesian statistics.

Reference: Gamma distribution — Wikipedia