# How to generate random failure time conditional to a lower bound

For my Monte Carlo simulation (job related) I needed to generate random numbers with conditional probability of related distribution. (example: given that an item has been working for 1200 hours, generating a proper random failure time related to its time-to-failure distribution.)

I searched the web and couldn't find a formula or process to generate this kind of dataset.

In my case I am only interested in 2 distributions:

1. exponential
2. weibull

Question 1: My opinion for exponential is "Since exponential distribution has memoryless property then generating random number with conditional probability is still same as generating random number without any condition."

Am I right?

Question 2: I couldn't find any source for weibull distribution. Can you please help me on how to generate weibull random number with conditional probability.

If I understand correctly, you are correct concerning exponential distribution: the failure time $T$, conditional to $T > t_1$, is $t_1 + T'$ with $T' \sim \mathcal E(\lambda)$.
Weibull distribution has the property (which may be used as a definition) that $$Pr( T > t ) = e^{-\left( {t\over \lambda} \right)^k}.$$ Thus, the distribution of the failure time conditional to $T > t_1$ verifies $$Pr( T > t_1 + t | T > t_1) = e^{ -{1\over \lambda^k}\left( (t_1+t)^k - t_1^k\right) }.$$ You can generate $T$ as $t_1 + T'$ with $T'$ having the above distribution. This can be done by inverse transform sampling.
Concretely, if $U$ is uniform on $(0,1)$, let $T' = F^{-1}(U)$ with $F(t) = 1-e^{ -{1\over \lambda^k}\left( (t_1+t)^k - t_1^k\right) }$, that is $$T' = \left(t_1^k - \lambda^k \log(1-U) \right)^{1\over k} - t_1,$$ where $\log$ is the natural logarithm. You can simplify this by noting that $U$ and $1-U$ have the same distribution so $\log U$ will do it.
• thank you so much for your quick and detailed help Elvis. $\log U$ is I think $\ln U$ with base e; right? May 22 '17 at 8:34
• You can test the formula by generating samples 1) using the formula, and 2) using rejection sampling (generate many $T$ values and keep only values above $t_1$). Compare the two samples with e.g. a qq-plot. Good luck! May 22 '17 at 8:54