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?
 A: Let $\mathscr{C}_1$ and $\mathscr{C}_2$ denote classes 1 and 2 respectively.  Since $X \sim \text{Ga}(\alpha, \beta)$ you have:
$$\begin{equation} \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} \end{equation}$$
where $\gamma$ is the lower incomplete beta function.  Similarly, you have:
$$\begin{equation} \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} \end{equation}$$
where $\Gamma$ is the upper incomplete gamma function.
