# Simulating from a piecewise distribution

I have the following density function:

$$f(t)=\begin{cases} 0.8\exp(-2t)+0.5 \sqrt\frac{2}{\pi}\exp(-\frac{t^2}{2}) \text{, if } t > 2 \\0.8\exp(-2t)+0.5 \sqrt\frac{2}{\pi}\exp(-\frac{t^2}{2})+0.05 \text{, if } 0 \leq t \leq 2 \\ 0, \text{otherwise} \end{cases}$$

How can I use a uniform distribution and possibly others such as (exponential and normal) to generate samples from this distribution?

If $$t$$ was finite, I could spit up the $$t$$ axis into chunks, then use a uniform random variable generator and take those values as CDF values and map it to $$t$$.

Not sure how to start here. Can we consider a probability of $$0.5$$ that $$t$$ is either less than $$2$$ or greater than $$2$$?

Your probability density function is a linear combination of pdf's of the following three random variables with weights $$0{.}5$$, $$0{.}4$$ and $$0{.}1$$ correspondingly:
1) absolute value of standard normal $$|X|$$, $$X\sim \mathcal N(0,1)$$,
2) exponential $$Y$$ with mean $$\frac12$$,
3) uniform $$Z$$ on the interval $$(0,\,2)$$.
So you can simulate random choice with probabililties $$0{.}5$$, $$0{.}4$$ and $$0{.}1$$ of the simulated value of these random variables.