3

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?

Stephan Kolassa
  • 95,027
  • 13
  • 197
  • 357
M N
  • 53
  • 2

1 Answers1

4

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.

Stephan Kolassa
  • 95,027
  • 13
  • 197
  • 357
  • Thank you Stephan! The reference is helpful too (I need to figure out how to get access) but do you know if this is something we can compute in excel directly? – M N Jun 10 '20 at 11:13
  • Have you tried simply clicking on "Download this paper" at the top of the SSRN page? Regarding Excel: it looks like there are ways to calculate [the incomplete gamma function](https://duckduckgo.com/?t=ffsb&q=excel+incomplete+gamma&ia=web). Just be careful you use a function definition that matches this one (or you translate accordingly), there are multiple definitions floating around, – Stephan Kolassa Jun 10 '20 at 11:51