Conditional expectation of a Weibull distributed random variable Let $X$ be a Weibull Distributed random variable. I want to calculate $E[X\mid X \in [a,b]]$, where $a>0$, $b>0$. Is there a closed form solution for this, and if so, how can I calculate it?
 A: What you are looking for is the expectation of a truncated Weibull distribution. "Truncated Weibull Distribution Functions and Moments" by François Crénin gives you the formula you need. Let $\alpha$ denote the shape and $\beta$ the scale of the Weibull, then
$$ E(X|a<X<b) = 
\frac{\beta}{e^{-\left(\frac{a}{\beta}\right)^\alpha}-e^{-\left(\frac{b}{\beta}\right)^\alpha}}\bigg[\gamma\left(\frac{1}{\alpha}+1,\left(\frac{b}{\beta}\right)^\alpha\right)-\gamma\left(\frac{1}{\alpha}+1,\left(\frac{a}{\beta}\right)^\alpha\right)\bigg].
 $$
I like verifying calculations like this using an R script, like this (note that pracma::gammainc() switches the order of the two parameters of the lower incomplete gamma function compared to the formulation I took from the paper):
require(pracma)

shape <- 1
scale <- 4
aa <- 2
bb <- 3

set.seed(1)
foo <- rweibull(1e5,shape,scale)
mean(foo[foo>aa & foo<bb])

scale*(gammainc((bb/scale)^shape,1/shape+1)["lowinc"]-gammainc((aa/scale)^shape,1/shape+1)["lowinc"])/
    (exp(-(aa/scale)^shape)-exp(-(bb/scale)^shape))

The two last commands give the same result up to noise, also for other values of the parameters.
