<s>[INST] Density function for a random variable having a mixed distribution 
*

*A random variable has the following mixed distribution (ie: A distribution that is both discrete and continuous):


$P_{X}=\frac{1}{3}E(1)+\frac{2}{3}B(\frac{1}{2})$,

where $E(1)$ is the exponential distribution with $\lambda=1$ and $B(1/2)$ is the Bernoulli distribution with p=1/2. What is the density function for $P_{X}$?
I'd also like to know what $\textbf{E}X$ and $\operatorname{Var}(X)$ is, as well as the Characteristic function.
 [/INST] Let $Y \sim {\rm Exponential}(\lambda = 1)$ and $Z \sim {\rm Bernoulli}(p = 0.5)$.  Then $X = \tfrac{1}{3}Y + \tfrac{2}{3}Z$, and we easily see that $$(X \mid Z = 0) = \tfrac{1}{3}Y \sim {\rm Exponential}(\lambda = 3);$$ i.e., $$f_{X \mid Z = 0}(x) = \begin{cases} 3e^{-3x}, & x \ge 0 \\ 0, & x < 0. \end{cases}$$  Similarly, $$(X \mid Z = 1) = \tfrac{1}{3}Y + \tfrac{2}{3}$$ is a shifted exponential, with density $$f_{X \mid Z = 1}(x) = \begin{cases} 3e^{-3x+2}, & x \ge \tfrac{2}{3} \\ 0, & x < \tfrac{2}{3}. \end{cases}$$  Consequently, the unconditional density is given by $$\begin{align*} f_X(x) &= f_{X \mid Z = 0}(x) \Pr[Z = 0] + f_{X \mid Z = 1}(x) \Pr[Z = 1] \\ &= \begin{cases}0, & x < 0 \\ \frac{3}{2}e^{-3x}, & 0 \le x < \frac{2}{3}, \\ \frac{3}{2}e^{-3x} + \frac{3}{2}e^{-3x+2}, & x \ge \frac{2}{3}. \end{cases} \end{align*}$$  The last part of the piecewise function can also be written as $\frac{3}{2}(1+e^2)e^{-3x}$.  The expectation and variance are easily calculated because $Y$ and $Z$ are independent:  $${\rm E}[X] = \tfrac{1}{3}{\rm E}[Y] + \tfrac{2}{3}{\rm E}[Z] = \tfrac{1}{3} \cdot 1 + \tfrac{2}{3}\cdot \tfrac{1}{2} = \tfrac{2}{3},$$ and $${\rm Var}[X] = \bigl(\tfrac{1}{3}\bigr)^2 {\rm Var}[Y] + \bigl(\tfrac{2}{3}\bigr)^2 {\rm Var}[Z] = \tfrac{1}{9} \cdot 1^2 + \tfrac{4}{9} \cdot \tfrac{1}{2} \bigl(1 - \tfrac{1}{2}\bigr) = \tfrac{2}{9}.$$
</s>