# Mixing a discrete random variable with continuous random variables

I have a discrete random variable $Y$ with $\mathbb{P}(Y=i) := p_i, i = 1, \dots, n$. Additionally, let $X_1, \dots, X_n$ denote a sequence of random variables which are all independent from $Y$. Now let $Z = X_Y$ be the random variable which occurs when we use $Y$ to choose which of the $X_i$ we use.

My question is: How can this random variable $Z$ be understood or defined? I am not quite sure how to work with this $Z$. One idea of mine would be to intuitively define $$Z = \sum_{i=1}^np_i X_i$$ But when I want to calculate $\mathbb{P}(Z \in A)$ I could also say that $$\mathbb{P}(Z \in A) = \mathbb{P}(\bigcup_{i=1}^n(\{Y=i\} \cap \{X_i \in A\}))=\sum_{i=1}^np_i\mathbb{P}(X_i \in A)$$

The problem I am having is, I am not sure if the way I am calculating the probabilty of $Z$ can actually follow from the representation of $Z$ as a sum. The way I calculated the probability was also just an intuitive approach. Using the sum representation I would get $$\mathbb{P}(Z\in A) = \mathbb{P}(\sum_{i=1}^np_i X_i \in A)$$ which I could not really directly simplify.

Any help would be appreciated!

The sum $Z = \sum p_i X_i$ is not the same as what you describe in the first paragraph. The definition from the first paragraph could perhaps be written as $$Z = X_Y .$$ Edit: Whoops you do write it in the first paragraph!

To see that this is true, suppose that $Y \sim \mathrm{Bernoulli}\left(\frac12\right)$ and $X_i\sim \mathrm U[i,i]$ (that is, $X_i$ are not random). Then $\sum p_i X_i \sim \mathrm U\left[\frac12,\frac12\right]$ but $X_Y \sim \mathrm{Bernoulli}\left(\frac12\right).$ They can’t both be right. The first line that you wrote for $\mathbb P(Z\in A)$ is consistent with the description in the first paragraph.

• Thanks, that makes sense! So there is no better way to explicitly say what $Z(\omega)$ would be other than saying that $Z(\omega) = X_i (\omega)$ for $Y=i$, $i= 1, \dots, n$. Is this correct? – Jack4t3 Dec 5 '17 at 13:53
• I think the way you described it in the question was better. You could say “let $Y$ be a random variable over $\{1,...,n\}$ and $X_i$ a family of random variables indexes by the same set. Then let $Z=X_Y.$” but depending a little on context, it ought to be ok to just say $Z=X_Y.$ – Dan Robertson Dec 5 '17 at 13:58

Use Total Law of Probability,in the sense that $$P(Z<z) = P(X_1<z|Y=y_1).P(Y=y_1)+\cdots + P(X_n<z|Y= y_n).P(Y=y_n)$$

Unless I have misunderstood what you want to do!!