# 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 Aug 20 '18 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 y^\alpha e^{-y} dy }{ \int_0^T y^{\alpha-1} e^{-y} dy } \\[6pt] &= \beta \cdot\frac{ \gamma(\alpha+1,T) }{ \gamma(\alpha,T) }, \\[6pt] \end{aligned}
where $\gamma$ is the lower incomplete beta 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^\infty y^\alpha e^{-y} dy }{ \int_T^\infty y^{\alpha-1} e^{-y} dy } \\[6pt] &= \beta \cdot\frac{ \Gamma(\alpha+1,T) }{ \Gamma(\alpha,T) }, \\[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)$$ – Martijn Weterings Aug 21 '18 at 10:45