I am having trouble in simulating values for a random variable $X$ having a piecewise gamma failure rate: $$ \lambda_X(t) =\lambda_1(t)1\!\!1_{\lbrace t\leq t_0 \rbrace} + \lambda_2(t)1\!\!1_{\lbrace t > t_0 \rbrace}$$ where $\lambda_1$ and $\lambda_2$ are the failure rates of two Gamma distributions $\Gamma(\alpha_1,\beta_1)$ and $\Gamma(\alpha_2,\beta_2)$ respectively. The value of $t_0$ and the parameters of Gamma distributions are known in advance.

Apparently the change point $t_0$ doesnot allow simulating two independant gamma random variables. Does anyone have a solution? Thanks in advance.

  • $\begingroup$ Do you want to simulate a random variable X at time $t$ or a stochastic process $(X_t)$ in continuous time or do you want to invert the failure rate into a distribution ? $\endgroup$ – Xi'an Jun 25 '15 at 16:52
  • 1
    $\begingroup$ I want to simulate samples $x_1,x_2,...,x_n$ for the r.v. X. I think you hit the right spot when proposing "invert the failure rate into a distribution", because that what I am taught in simulation courses for simple distributions like the normal or exponential (then using the probability transformation property to simulate the samples). However, I am not sure how to proceed for this kind of distribution $\endgroup$ – Tuan Jun 25 '15 at 17:01

As a general rule, when given the failure rate$$\eta(t)=\frac{f(t)}{\int_t^\infty f(x)\,\text{d}x}=-\frac{\text{d}}{\text{d}t}\,\log \int_t^\infty f(x)\,\text{d}x$$we can formally derive$$\int_0^t\eta(x)\,\text{d}x=-\log \int_t^\infty f(x)\,\text{d}x$$since the value at $t=0$ is zero on both sides, and$$\exp\left\{-\int_0^t\eta(x)\,\text{d}x\right\}=1-\int_0^t f(x)\,\text{d}x$$which leads to the cdf$$F(t)=\int_0^t f(x)\,\text{d}x=1-\exp\left\{-\int_0^t\eta(x)\,\text{d}x\right\}$$From a simulation perspective, if we generate $U\sim\mathcal{U}(0,1)$, we have to solve $F(X)=U$, which means $$1-\exp\left\{-\int_0^X\eta(x)\,\text{d}x\right\}=U$$or$$\int_0^X\eta(x)\,\text{d}x=-\log(1-U)$$ Now, when $\eta(x)=\lambda_1(x)\mathbb{I}_{x\le t_0}+\lambda_2(x)\mathbb{I}_{x>t_0}$, this means that $$F(x)=\cases{F_1(x) &when $x<t_0$\\ 1-\{1-F_1(t_0)\}\dfrac{1-F_2(x)}{1-F_2(t_0)} &else}$$ where $F_1$ is the Gamma $G(\alpha_1,\beta_1)$ cdf and $F_2$ the Gamma $G(\alpha_2,\beta_2)$ cdf. Equivalently, $$F(x)=\cases{F_1(t_0)\mathbb{P}(X_1\le x|X_1\le t_0) &when $x<t_0$\\ F_1(t_0)+\{1-F_1(t_0)\}\mathbb{P}(X_2\le x|X_2\ge t_0) &else}$$where $X_1$ and $X_2$ denote Gamma $G(\alpha_1,\beta_1)$ and Gamma $G(\alpha_2,\beta_2)$ random variables.

Conclusion This representation of the cdf establishes that the distribution with failure rate$$\eta(x)=\lambda_1(x)\mathbb{I}_{x\le t_0}+\lambda_2(x)\mathbb{I}_{x>t_0}$$is a mixture of a Gamma $G(\alpha_1,\beta_1)$ truncated to $(0,t_0)$ and of a Gamma $G(\alpha_2,\beta_2)$ truncated to $(t_0,\infty)$ with weights $F_1(t_0)$ and $(1-F_1(t_0))$.

In terms of random simulation this means

  1. pick the generating distribution Gamma $G(\alpha_1,\beta_1)$ truncated to $(0,t_0)$ with probability $F_1(t_0)$ and the generating distribution Gamma $G(\alpha_2,\beta_2)$ truncated to $(t_0,\infty)$ with probability $1-F_1(t_0)$
  2. Generate X from the picked truncated Gamma distribution
| cite | improve this answer | |
  • $\begingroup$ If I understand correctly, you are suggesting that the r.v. $X$ is a mixture of two independant and weighted truncated Gamma distributions? Following your developpement, the question (and solution) can be generalized to almost any distribution. $\endgroup$ – Tuan Jun 25 '15 at 18:25
  • $\begingroup$ I am worried by your use of "independent": the density of the distribution is of the form$$F_1(t_0)g_1(x)+(1-F_1(t_0))g_2(x)$$where $g_1$ and $g_2$ are the densities of the two truncated gammas. There is no notion of "independence" involved. $\endgroup$ – Xi'an Jun 25 '15 at 19:30
  • $\begingroup$ Thanks for your concern. What I meant by independent (maybe I am wrong) is that it seems there is no connection between $g_1$ and $g_2$ (well there is $t_0$ but not in the sense of conditional probability for example). My intuition should be wrong, since your reasoning is flawfless. $\endgroup$ – Tuan Jun 25 '15 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.