# Mean of truncated gamma distribution using threshold

Given a gamma distribution with PDF:

$f(x;\alpha;\beta) = \frac{x^{\alpha-1} e^{-\frac{x}{\beta}}}{\Gamma(\alpha) \beta^\alpha}$

with a shape parameter $\alpha > 0$, a scale parameter $\beta > 0$ and $\Gamma(k)$ the gamma function.

The mean is then $\alpha\beta$ and variance $\alpha\beta^2$, hence

$\alpha = \frac{1}{Var(X) \lambda^2},\ \beta = Var(X) \lambda\$

Samples from this gamma distribution are divided into 2 classes, samples smaller than a certain threshold T, and samples larger than or equal to T.

What is the mean of class 1 and class 2, in this case?

• Presumably $f$ is the PDF and $x \gt 0.$ Essentially by definition, the answers must be expressed in terms of the incomplete Gamma function, except when $\alpha$ is a small integer.
– whuber
Commented Aug 20, 2018 at 13:48

Let $$\mathscr{C}_1$$ and $$\mathscr{C}_2$$ denote classes 1 and 2 respectively. Since $$X \sim \text{Ga}(\alpha, \beta)$$ you have:

\begin{aligned} \mathbb{E}(X | X \in \mathscr{C}_1) = \mathbb{E}(X | X < T) &= \frac{\mathbb{E}(X \cdot \mathbb{I}(X < T))}{\mathbb{P}(X < T)} \\[6pt] &= \frac{ \int_0^T x \cdot \text{Ga}(x|\alpha, \beta) dx }{ \int_0^T \text{Ga}(x|\alpha, \beta) dx } \\[6pt] &= \frac{ \int_0^T x^\alpha e^{-x/\beta} dx }{ \int_0^T x^{\alpha-1} e^{-x/\beta} dx } \\[6pt] &= \beta \cdot \frac{ \int_0^T (x/\beta)^\alpha e^{-x/\beta} dx }{ \int_0^T (x/\beta)^{\alpha-1} e^{-x/\beta} dx } \\[6pt] &= \beta \cdot\frac{ \int_0^{T/\beta} y^\alpha e^{-y} dy }{ \int_0^{T/\beta} y^{\alpha-1} e^{-y} dy } \\[6pt] &= \beta \cdot\frac{ \gamma(\alpha+1,T/\beta) }{ \gamma(\alpha,T/\beta) }, \\[6pt] \end{aligned}

where $$\gamma$$ is the lower incomplete gamma function. Similarly, you have:

\begin{aligned} \mathbb{E}(X | X \in \mathscr{C}_2) = \mathbb{E}(X | X \geqslant T) &= \frac{\mathbb{E}(X \cdot \mathbb{I}(X \geqslant T))}{\mathbb{P}(X \geqslant T)} \\[6pt] &= \frac{ \int_T^\infty x \cdot \text{Ga}(x|\alpha, \beta) dx }{ \int_T^\infty \text{Ga}(x|\alpha, \beta) dx } \\[6pt] &= \frac{ \int_T^\infty x^\alpha e^{-x/\beta} dx }{ \int_T^\infty x^{\alpha-1} e^{-x/\beta} dx } \\[6pt] &= \beta \cdot \frac{ \int_T^\infty (x/\beta)^\alpha e^{-x/\beta} dx }{ \int_T^\infty (x/\beta)^{\alpha-1} e^{-x/\beta} dx } \\[6pt] &= \beta \cdot\frac{ \int_{T/\beta}^\infty y^\alpha e^{-y} dy }{ \int_{T/\beta}^\infty y^{\alpha-1} e^{-y} dy } \\[6pt] &= \beta \cdot\frac{ \Gamma(\alpha+1,T/\beta) }{ \Gamma(\alpha,T/\beta) }, \\[6pt] \end{aligned}

where $$\Gamma$$ is the upper incomplete gamma function.

• The ratio of the two incomplete gamma functions can be changed into an expression with a single incomplete gamma function using the property $$\gamma(\alpha+1,T) = \alpha\gamma(\alpha,T)-T^\alpha e^{-T}$$ such that we can write $\mathbb{E}f_T(x)$ also like: $$\mathbb{E}f_T(x) = \beta \frac{\gamma(\alpha+1,T)}{\gamma(\alpha,T)} = \beta \left( \alpha - \frac{T^\alpha e^T}{ \gamma(\alpha,T) }\right)$$ Commented Aug 21, 2018 at 10:45
• Fair enough, though I'm not convinced that that form is any simpler.
– Ben
Commented May 13, 2023 at 2:09
• I do not know anymore why I came up with that 'simplification' 5 years ago. Possibly I just saw the ratio with only the small and integer valued difference in the parameters $\alpha$ and $\alpha +1$ and was curious whether that could be simplified. Well that final function has a gamma function less, but it is indeed not particularly simpler. Nowadays I would stress the $\alpha\beta$ term and write it as $$\beta\alpha - \frac{\beta T^\alpha e^T}{ \gamma(\alpha,T)}$$ Commented May 13, 2023 at 7:57

I wanted to comment but I don't have enough reputation to comment. So I hope this will be allowed to stay as an "answer". There's an error in Ben's derivation: when switching variables from $$x$$ to $$y=x/\beta$$, the limit of integration $$T$$ needs to be changed to $$T/\beta$$ (so scale is taken out). Thus the result (also using Sextus Empiricus's simplification) is $$\mathbb{E}[X\mid X That is, truncation at $$T$$ reduces the mean by $$\displaystyle\beta\frac{(T/\beta)^\alpha e^{-T/\beta}}{\gamma(\alpha,T/\beta)}$$.

EDIT AFTER A FEW DAYS: I just realized that we can also write the truncated mean as $$\mathbb E[X\mid X This form may be easier for computation using pdf/cdf functions (I am thinking R). It's also intuitive: if we take $$T$$ to $$\infty$$, the second term in brackets vanishes, and we recover the Gamma mean $$\alpha\beta$$.