# Three-bean salad probability density problem

A recipe for three-bean salad includes three different types of beans, $$A$$, $$B$$, and $$C$$. Let the relative weights (masses) of the three bean varieties in a given batch of salad be represented by $$X$$, $$Y$$, and $$Z$$, respectively, such that $$X + Y + Z = 1$$. And let the joint probability density of $$X$$ and $$Y$$ be given by $$f(x,y)=kx^2y$$ for $$x>0$$, $$y>0$$, and $$x+y<1$$, and $$f(x,y) = 0$$ otherwise.

Here is a graph of the joint probability density of $$(X,Y)$$; that is, the above equation is only valid in the shaded region.

a. Find $$k$$.

To calculate what $$k$$ is, we first have to realize that $$P(-\infty < X < \infty, -\infty < Y < \infty) = 1$$, so $$\begin{eqnarray} \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} f(x,y) \, dx \, dy &=& 1 \nonumber \\[9pt] \int_0^1 \int_0^{1-y} k x^2 y \, dx \, dy &=& 1 \nonumber \\[9pt] k \int_0^1 \left[\dfrac{1}{3}yx^3 \right]_0^{1-y} \, dy &=&1 \nonumber \\[9pt] k \int_0^1 -\frac{1}{3}y^4 + y^3 - y^2 + \frac{1}{3}y ~ \, dy &=&1 \nonumber \\[9pt] k \left[-\frac{1}{15}y^5 + \frac{1}{4}y^4 - \frac{1}{3}y^3 + \frac{1}{6}y^2\right]_0^1 &=& 1 \nonumber \\[9pt] k \left(\frac{1}{60} \right) &=& 1 \nonumber \\[9pt] k &=& 60 \\ \end{eqnarray}$$ b. Assuming $$X$$, $$Y$$, and $$Z$$ are random variables, what is the probability that bean variety $$A$$ makes up more than half the weight of beans in a given batch?

This question is asking for the probability $$P(X > 0.5)$$. All we really need to do is add another line to our pdf graph, $$x=0.5$$, and re-integrate with new bounds of integration.

From the graph, we can see that the probability density of the shaded region is

$$\begin{eqnarray} P(X > 0.5) &=& \int_0^{0.5} \int_{0.5}^{1-y} 60x^2y \, dx \, dy \nonumber \\[9pt] &=& 60\int_0^{0.5} \left[\frac{1}{3}yx^3\right]_{0.5}^{1-y} \, dy \nonumber \\[9pt] &=& 60\int_0^{0.5} -\frac{1}{3}y^4 + y^3 – y^2 + \frac{1}{3}y ~- \frac{1}{24}y ~ \, dy \nonumber \\[9pt] &=& 60\int_0^{0.5} -\frac{1}{3}y^4 + y^3 – y^2 + \frac{7}{24}y ~ \, dy \nonumber \\[9pt] &=& 60 \left[-\frac{1}{15}y^5 + \frac{1}{4}y^4 – \frac{1}{3}y^3 + \frac{7}{48}y^2 \right]_0^{0.5} \nonumber \\[9pt] &=& 60 \left(\frac{1}{120} \right) \nonumber \\[9pt] &=& 0.5 \end{eqnarray}$$

c. What is the probability that bean variety $$C$$ makes up more than half of the bean weight?

This question is asking for $$P(Z > 0.5)$$, which is to say $$P(X+Y\leq0.5)$$. We need yet another graph to help us define the region of the pdf that accounts for this probability.

Setting up the integrals is basically the same as above:
$$\begin{eqnarray} P(Z>0.5) &=& \int_0^{0.5} \int_0^{0.5-y} 60x^2y \, dx \, dy \nonumber \\[9pt] &=& 60 \int_0^{0.5} \left[\frac{1}{3}yx^3 \right]_0^{0.5-y} \, dy \nonumber \\[9pt] &=& 60 \int_0^{0.5} -\frac{1}{3}y^4 + \frac{1}{2}y^3 – \frac{1}{4}y^2 + \frac{1}{24}y ~ \, dy \nonumber \\[9pt] &=& 60 \left[-\frac{1}{15}y^5 + \frac{1}{8}y^4 – \frac{1}{12}y^3 + \frac{1}{48}y^2 \right]_0^{0.5} \nonumber \\[9pt] &=& 60\left(\frac{1}{1920}\right) \nonumber \\[9pt] &=& \frac{1}{32} \end{eqnarray}$$

d. Probability that none of the three varieties will take up more than half the weight.

This question is asking for $$P(X\leq0.5, Y\leq0.5, Z\leq0.5)$$, which equals $$P(X\leq0.5, Y\leq0.5, X+Y > 0.5)$$. Thus, the region for this probability is between $$y = 0.5$$, $$x = 0.5$$, and $$x+y = 0.5$$:

$$\begin{eqnarray} P(X\leq0.5, Y\leq0.5, X+Y > 0.5) &=& \int_0^{0.5} \int_{0.5-y}^{0.5} 60x^2y \, dx \, dy \nonumber \\[9pt] &=& 60 \int_0^{0.5} \left[\frac{1}{3}yx^3 \right]_0^{0.5-y} \, dy \nonumber \\[9pt] &=& 60 \int_0^{0.5} \frac{1}{24}y \left(-\frac{1}{3}y^4 + \frac{1}{2}y^3 – \frac{1}{4}y^2 + \frac{1}{24}y\right) ~ \, dy \nonumber \\[9pt] &=& 60 \left[\frac{1}{15}y^5 – \frac{1}{8}y^4 + \frac{1}{12}y^3 \right]_0^{0.5} \nonumber \\[9pt] &=& 60\left(\frac{3}{640}\right) \nonumber \\[9pt] &=& \frac{9}{32} \end{eqnarray}$$

e. Marginal density of $$(X, Z)$$.

We can calculate this marginal probability function by simply replacing $$Y$$ in the given density function with $$1-X-Z$$. This is because, with the given restriction that $$X+Y+Z=1$$, we have two degrees of freedom in the values of our variables, and we have a joint density function with two variables, i.e., $$f(x,y) = 60x^2y$$, so we can use $$X+Y+Z=1$$ to easily find the marginal probability function of either $$(X, Z)$$ or $$(Y, Z)$$. Substituting $$Y$$ with $$1-X-Z$$ gives us $$f(x,z) = 60x^2(1-x-z) = 60x^2 – 60x^3 – 60x^2z$$.

f. Marginal density of $$Z$$ alone.

Recall that the marginal density of a variable (or even two or more variables) is the probability density of that variable(s) irrespective of the values of the other variables. Since the marginal density of a variable(s) does not take into account anything about the other variable(s), we must determine the density of the former over all possible values of the latter. Thus, we calculate the marginal probability density of a continuous variable by integrating the joint probability function over all the possible values of the other variables.

In this case, it might not be obvious what function we need to integrate, and what variables we need to integrate with respect to. To wit, we don’t integrate the original density function of $$(X, Y)$$; rather, we integrate $$f(x,z)$$ over all possible values of $$x$$, to get the marginal density of $$z$$. This is the only function we have with $$z$$ in it, so it’s the one we use. Finally, the bounds of $$x$$ are $$0$$ to $$1-z$$; to see this, note that since the original density function was valid for $$y>0$$, and since $$y=1-x-z$$, the new function $$f(x,z)$$ is valid for $$1-x-z>0$$, or $$x<1-z$$. $$\begin{eqnarray} f_z (z) &=& \int_0^{1-z} 60x^2 - 60x^3 - 60x^2 z \, dx \nonumber \\[9pt] &=& 60 \left[\frac{1}{3}x^3 - \frac{1}{4}x^4 - \frac{1}{3}x^3z \right]_0^{1-z} \nonumber \\[9pt] &=& 60 \left[\frac{1}{3}(1-z)^3 - \frac{1}{4}(1-z)^4 - \frac{1}{3}z(1-z)^3 \right] \nonumber \\[9pt] &=& 60 \left[\frac{1}{3}(1-z)^3(1-z) - \frac{1}{4}(1-z)^4 \right] \nonumber \\[9pt] &=& 60 \left[\frac{1}{3}(1-z)^4 - \frac{1}{4}(1-z)^4 \right] \nonumber \\[9pt] &=& 60\left(\frac{1}{12}\right)(1-z)^4 \nonumber \\[9pt] &=& \frac{1}{5}(1-z)^4 \end{eqnarray}$$

This entry was posted in Math. Bookmark the permalink.