# Finding the cumulative distribution of a mixture distribution of discrete and continuous variables

If I have a random variable that with probability 1/3 is a $U(1,2)$, with probability $1/3$ is $U(2,4)$ and with probability $1/3$ is a discrete rv that takes value 2 with probability $0.4$ and 3 with probability $0.6$ how do I calculate the cumulative distribution of this?

So after the comments and answer I will attempt to clarify this question. My uniform rv's are continuous. I am looking for the cumulative of this in order to generate random numbers with this distribution using inversion. This is a practice question and the solution is:

$$F(x)=\begin{cases} \frac{(x-1)}{3} & \mbox{if} \ 1<x<2 \\ \frac{7}{15} & \mbox{if} \ <x=2 \\ \frac{(5x+4)}{30} & \mbox{if} \ 2<x<3 \\ \frac{25}{30} & \mbox{if} \ x=3 \\ \frac{(5x+10)}{30} & \mbox{if} \ 3<x<4 \end{cases}$$

I just have no idea how this solution was derived?

• Please add the [self-study] tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. Commented Apr 30, 2015 at 9:33
• See Wikipedia on finite mixtures, which has $F(x) = \sum_{i=1}^n \, w_i \, P_i(x)$, where the $P_i$ are the individual cdfs. Commented Apr 30, 2015 at 11:33
• Silverfish, are we sure that he wants us to use continuous distributions? Because a uniform distribution can be either discrete or continuous. Commented May 1, 2015 at 3:52
• @Silverfish I have added clarification which I hope helps, sorry it took so long I had an account merging problem. I also apologise for not adding the self-study tag, I didn't realize that it existed, this is however not homework it is a practice question- as can be seen I have an apparent solution. Commented May 5, 2015 at 8:23
• Good grief! I cannot believe that someone who is teaching probability/statistics has provided a practice question with answer the "CDF" as shown above. So, if $1 < x < 2$, does $F(x)$ equal $\frac{x-1}{3}$ or $\frac{5x+10}{30}$? You have it both ways. What is $F(x)$ when $x > 4$ etc? Commented May 5, 2015 at 11:33

1. The cumulative distribution function, or CDF, of a random variable $X$ is the function $F_X:\mathbb{R}\to\mathbb{R}$ defined by

$$F_X(x) = \Pr(X \le x).$$

2. A discrete random variable $X$ which takes on the values $(x_1, x_2, x_3, \ldots)$ with probabilities $(p_1, p_2, p_3, \ldots)$, respectively, therefore has distribution function

$$F_X(x) = \sum_{i\,|\, x_i \le x} p_i.$$

This can be written conveniently in terms of the Heaviside function

$$\theta(x) = \begin{array}{ll} \left\{ \begin{array}{ll} 0 & x \lt 0 \\ 1 & x\ge 0 \end{array}\right. \end{array}$$

via

$$F_X(x) = \sum_i p_i \theta(x-x_i).$$

3. To say that a random variable $X$ has a uniform distribution supported on $[a,b]$, written $X\sim U(a,b)$, means that its CDF rises linearly from $0$ at $x=a$ to $1$ at $x=b$. There is no probability that $X$ can lie outside the interval $[a,b]$, implying that $F_X(x)=0$ for $x\lt a$ and $F_X(x) = 1$ for $x\gt b$. To describe such a piecewise linear function, introduce the function

$$\Theta(x) = x^{+} = \max(0, x).$$

This function is $0$ for $x\lt 0$ and otherwise equals $x$ for $x\ge 0$. We may write

$$F_X(x) = \Theta(z) - \Theta(z-1)$$

where $z = (x-a)/(b-a)$.

4. A mixture of distributions $F_1, F_2, F_3, \ldots$ with weights $\omega_1, \omega_2, \omega_3, \ldots$, respectively, will be a distribution when the weights are non-negative and sum to unity. In that case the distribution function of the mixture is

$$F(x) = \sum_i \omega_i F_i(x).$$

The last definition enables us to write the answer immediately as

$$F(x) = \frac{1}{3}F_1(x) + \frac{1}{3} F_2(x) + \frac{1}{3} F_3(x)$$

where the first distribution $F_1$ is $U(1,2)$, the second $F_2$ is $U(2,4)$, and the third $F_3$ is discrete. Applying definitions (2) and (3) as appropriate enables us immediately to write

$$F_1(x) = \Theta\left(\frac{x-1}{2-1}\right) - \Theta\left(\frac{x-1}{2-1} - 1\right),$$

$$F_2(x) = \Theta\left(\frac{x-2}{4-2}\right) - \Theta\left(\frac{x-2}{4-2} - 1\right),$$

and

$$F_3(x) = 0.4 \theta(x - 2) + 0.6 \theta(x - 3).$$

Here are their graphs.

Plugging them into the formula for $F$ gives a solution. The remaining issue concerns how to simplify it. Arguably, one would usually not want to "simplify" this expression, because that would only obscure what it means and how to interpret it. One valid reason for a simplification would be to improve computation, but the separate computation of the $F_i$ is already so simple and fast that even this reason seems like a poor one.

However, it may be of interest to understand $F$ qualitatively. To this end, note that

• $F_1$ and $F_2$ are piecewise linear and continuous, but have "kinks" where a slope is not defined. (The slope, where defined, gives a value for a probability density function and therefore can be of some interest.)

• $F_3$ is piecewise constant, but contains jumps.

Because the mixture is a linear combination of the $F_i$ and linear combinations preserve linearity, we know immediately that $F$ is piecewise linear but may have kinks and jumps. Where are these interesting values located? They can be only where they might occur in the $F_i$. Looking at the plots (or the formulas, for those who prefer algebraic reasoning to geometric), it should be clear that a $U(a,b)$ distribution has kinks only at $\{a,b\}$--which is $\{1,2\}$ for $F_1$ and $\{2,4\}$ for $F_2$--and a discrete distribution has jumps only at its support $\{x_i\}$, which for $F_3$ is $\{2,3\}$. Therefore:

• $F$ can have jumps only at $\{2,3\}$.

• $F$ can have kinks only at $\{1,2,4\}$.

• $F$ must be linear in between any kinks or jumps.

Thus, $F$ must have a piecewise linear definition broken down on the intervals $x\lt 1$, $1\le x \lt 2$, $2 \le x \lt 3$, $3 \le x \lt 4$, and $x\ge 4$. To write this down explicitly--which is rarely needed--use your favorite methods to work out the formulas of linear functions.

$$F(x) = \begin{array}{cc} \left\{ \begin{array}{cc} 0 & x \lt 1 \\ \frac{1}{3}(x-1) & 1\le x\lt2 \\ \frac{1}{30} (5x+4) & 2\leq x\lt3 \\ \frac{1}{6}(x+2) & 3\leq x\lt 4 \\ 1 & x\ge 4. \\ \end{array}\right. \end{array}$$

This answer uses the word "immediately" three times at junctures where no thought was required: only rote substitution of formulas into other formulas or application of a definition was needed. These applications are fundamentally uninteresting. What is of interest, and worth remembering from doing such an exercise, is the idea that certain qualitative aspects of mixture distribution can easily be inferred from qualitative properties of their components. This question focuses on reasoning about properties of continuity (absence of jumps) and differentiability (absence of jumps or kinks).

This looks like homework and should be marked as such if it is.

To point you in the right direction, consider the fact that the events are independent, we know that for independent events a joint probability distribution is defined by multiplying the probabilities (or PMFs if you are working in continuous distributions) of each event together.

Then normalise and put the events together (ie divide each by 1/3) and you're done with creating the PMF.

If the uniform distributions are discrete (you need to clarify this!) then you can simply then take the summation as usual for finding the value of the CDF.

• It is difficult to reconcile this advice with the information given in the question, which describes a mixture distribution. Although that description could be construed in terms of conditional probabilities, it does not provide joint probabilities directly, nor are independence or normalization of any apparent relevance.
– whuber
Commented Apr 30, 2015 at 17:03
• You may have misunderstood me when I spoke about independence. You make one choice with probability 1/3. Based on that choice you then make another from one of three separate distributions, to obtain the total probability in such cases one can treat this as a combination of independent events and use multiplication to derive the total probability. Commented Apr 30, 2015 at 22:53
• My wording was probably unclear, I'll fix it when I get back to a computer... And it is also correct to refer to this as a mixture distribution I would think. Commented Apr 30, 2015 at 22:56
• I have added clarification to the question, I hope this helps. Sorry it took me so long to do, I had an account merging problem. Commented May 5, 2015 at 8:23

The solution provided by your instructor is incomplete since it does not specify the value of $F(x)$ for $x < 1$ and for $x \geq 4$. Be that as it may, what you need to do is to find, for each real number $x$, the probability that the random variable $X$ has value no larger than $x$, that is, find $P\{X \leq x\}$. The information given to you is that $A, B, C$ are mutually exclusive events of probability $\frac 13$ each, and that

• conditioned on the occurrence of $A$, $X$ is uniformly distributed on $(1,2)$,

• conditioned on the occurrence of $B$, $X$ is uniformly distributed on $(2,4)$,

• conditioned on the occurrence of $C$, $X$ takes on values $2$ and $3$ with probabilities $0.4$ and $0.6$ respectively.

The law of total probability tells us that

\begin{align} P\{X \leq x\} = P\{X \leq x\mid A\}P(A)+ P\{X \leq x\mid B\}P(B) +P\{X \leq x\mid C\}P(C) \end{align}

where we know $P(A)=P(B)=P(C) = \frac 13$ while the other terms need to be evaluated for each value of $x$. For example, if $x=1.5$, then we have that

$$P\{X \leq 1.5\mid A\} = 0.5, \quad P\{X \leq 1.5\mid B\} = P\{X \leq 1.5\mid C\} = 0$$ while if $x = 1.6$, $$P\{X \leq 1.5\mid A\} = 0.6, \quad P\{X \leq 1.5\mid B\} = P\{X \leq 1.5\mid C\} = 0$$ Do you see why? (If not, read the bulleted items above again). So we get that $$P\{X \leq 1.5\} = \frac{0.5}{3}, \quad P\{X \leq 1.6\} = \frac{0.6}{3}.$$ and after trying this for $x=1.1, 1.2$ etc., maybe we have a "Hey Ma! I think I see a pattern!" moment that allows us to jump to the conclusion that $$P\{X \leq x\} = \frac{x-1}{3} ~ \text{for all} ~ x \in (1,2).$$ Since $F(x)$ is, by definition, the value of $P\{X \leq x\}$, the above equation is exactly what the first line in your instructor's guide is saying.

Can you go on from here?