# 14.5 - Piece-wise Distributions and other Examples

14.5 - Piece-wise Distributions and other Examples

Some distributions are split into parts. They are not necessarily continuous, but they are continuous over particular intervals. These types of distributions are known as Piecewise distributions. Below is an example of this type of distribution

\begin{align*} f(x)=\begin{cases} 2-4x, & x< 1/2\\ 4x-2, & x\ge 1/2 \end{cases} \end{align*}

for $$0<x<1$$. The pdf of $$X$$ is shown below. The first step is to show this is a valid pdf. To show it is a valid pdf, we have to show the following:

1. $$f(x)>0$$. We can see that $$f(x)$$ is greater than or equal to 0 for all values of $$X$$.

2. $$\int_S f(x)dx=1$$.

\begin{align*} & \int_0^{1/2}2-4xdx+\int_{1/2}^1 4x-2dx\\ & = 2\left(\frac{1}{2}\right)-2\left(\frac{1}{4}\right)+2-2-\left[2\left(\frac{1}{4}\right)-1\right]\\ & = 1-\left(\frac{1}{2}\right)+2-2-\left(\frac{1}{2}\right)+1=2-1=1 \end{align*}

3. If $$(a, b)\subset S$$, then $$P(a<X<b)=\int_a^bf(x)dx$$. Lets find the probability that $$X$$ is between 0 and $$2/3$$.

$$P(X<2/3)=\int_0^{1/2} 2-4xdx+\int_{1/2}^{2/3} 4x-2dx=\frac{5}{9}$$

The next step is to know how to find expectations of piecewise distributions. If we know how to do this, we can find the mean, variance, etc of a random variable with this type of distribution. Suppose we want to find the expected value, $$E(X)$$.

\begin{align*}& E(X)=\int_0^{1/2} x(2-4x)dx+\int_{1/2}^1 x(4x-2)dx\\& =\left(x^2-\frac{4}{3}x^3\right)|_0^{1/2}+\left(\frac{4}{3}x^3-x^2\right)|_{1/2}^1=\frac{1}{2}\end{align*}

The variance and other expectations can be found similarly.

The final step is to find the cumulative distribution function. cdf. Recall the cdf of $$X$$ is $$F_X(t)=P(X\le t)$$. Therefore, for $$t<\frac{1}{2}$$, we have

$$F_X(t)=\int_0^t 2-4xdx=2x-x^2|_0^t=2t-2t^2$$

and for $$t\ge\frac{1}{2}$$ we have

\begin{align*} & F_X(t)=\int_0^{1/2}2-4xdx+\int_{1/2}^t 4x-2dx=\frac{1}{2}+\left(2x^2-2x\right)|_{1/2}^t\\ & =2t^2-2t+1 \end{align*}

Thus, the cdf of $$X$$ is

$$\begin{equation*} F_X(t)=\begin{cases} 2t-2t^2 & 0<t<1/2\\ 2t^2-2t+1 & 1/2\le t<1 \end{cases} \end{equation*}$$

## Example 14-9: Mixture Distribution

Let $$f_1(y)$$ and $$f_2(y)$$ be density functions, $$y$$ is a real number, and let $$a$$ be a constant such that $$0\le a\le 1$$. Consider the function

$$f(y)=af_1(y)+(1-a)f_2(y)$$

1. First, lets show that $$f(y)$$ is a density function. A density function of this form is referred to as a mixture density (a mixture of two different density functions). My research is based on mixture densities.

\begin{align*} & \int_{-\infty}^{\infty} af_1(y)+(1-a)f_2(y)dy=a\int f_1(y)dy+(1-a)\int f_2(y)dy\\ & = a(1)+(1-a)(1)=a+1-a=1 \end{align*}

2. Suppose that $$Y_1$$ is a random variable with density function $$f_1(y)$$ and that $$E(Y_1)=\mu_1$$ and $$Var(Y_1)=\sigma^2_1$$; and similarly suppose that $$Y_2$$ is a random variable with density function $$f_2(y)$$ and that $$E(Y_2)=\mu_2$$ and $$Var(Y_2)=\sigma^2_2$$. Assume that $$Y$$ is a random variable whose density is a mixture of densities corresponding to $$Y_1$$ and $$Y_2$$.

1. We can find the expected value of $$Y$$ in terms of $$a, \;\mu_1, \text{ and } \mu_2$$.

\begin{align*} & E(Y)=\int yf(y)dy=\int y(af_1(y)+(1-a)f_2(y))dy\\ & = a\int yf_1(y)dy + (1-a) \int yf_2(y)dy=\\ & =a\mu_1+(1-a)\mu_2 \end{align*}

2. We can also find the variance of $$Y$$ similar to the above.

\begin{align*} & E(Y^2)=\int ay^2f_1(y)+(1-a)y^2f_2(y)dy=aE(Y_1^2)+(1-a)E(Y_2^2)\\ & =a(\mu_1^2+\sigma^2_1)+(1-a)(\mu_2^2+\sigma_2^2)\\ & Var(Y)=E(Y^2)-E(Y)^2 \end{align*}

1. A random variable $$X$$ has the following probability density function:

\begin{align*} f(x)=\begin{cases} \frac{1}{8}x & 0\le x\le 2\\ \frac{1}{4} & 4\le x\le 7 \end{cases}. \end{align*}

1. Find the cumulative distribution function (CDF) of $$X$$.

We should do this in pieces:

$$F(x)=\int_0^x\frac{1}{8}xdx=\frac{x^2}{16}, \qquad 0\le x\le 2$$

Between 2 and 4, the cdf remains the same. Therefore,

$$F(x)=\frac{2^2}{16}=\frac{1}{4}, \qquad 2\le x<4$$

After 4, the cdf becomes:

$$F(x)=\frac{1}{4}+\int_4^x\frac{1}{4}dx=\frac{1}{4}+\frac{1}{4}x-1=\frac{x-3}{4}, \qquad 4\le x\le 7$$

Therefore, we have:

$$F(x)=\begin{cases}0, & x<0\\ \frac{x^2}{16}, & 0\le x<2\\ \frac{1}{4}, & 2\le x<4\\ \frac{x-3}{4}, & 4\le x\le 7\\ 1, & x>7 \end{cases}$$

2. Find the median of $$X$$. It helps to plot the CDF.

The median is between 4 and 7 and $$P(X<4)=\frac{1}{4}$$. Let $$m$$ denote the median.

$$0.5=F(m)=\frac{m-3}{4}\qquad \Rightarrow m-3=2 \qquad \Rightarrow m=5$$.

2. Let $$X$$ have probability density function $$f_X$$ and cdf $$F_X(x)$$. Find the probability density function of the random variable $$Y$$ in term of $$f_X$$, if $$Y$$ is defined by $$Y=aX+b$$. HINT: Start with the definition of the cdf of $$Y$$.

$$F_Y(y)=P(Y\le y)=P(aX+b\le y)=P\left(X\le \frac{y-b}{a}\right)=F_X\left(\frac{y-b}{a}\right)$$

We know $$\frac{\partial }{\partial y}F_Y(y)=f_Y(y)$$. Therefore,

$$f_Y(y)=\frac{\partial }{\partial y}F_Y(y)=\frac{\partial }{\partial y}F_X\left(\frac{y-b}{a}\right)=f_X\left(\frac{y-b}{a}\right)\left(\frac{1}{a}\right)$$

  Link ↥ Has Tooltip/Popover Toggleable Visibility