Solved – Finding the cumulative distribution of a mixture distribution of discrete and continuous variables

cumulative distribution functionmixture-distributionprobabilityself-study

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?

Best Answer

Let's start with the definitions.

  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.

Figure: Plots of the CDFs

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.

Figure 2: Graph of F

$$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).