The joint distribution of random variables and is a probability distribution on pairs, and describes how the values of and vary together or jointly.
We can also study conditional distributions of random variables given the values of some random variables. How does the distribution of change for different values of (and vice versa)?
Example 14.1 Roll a fair four-sided die twice. Let be the sum of the two rolls, and let be the larger of the two rolls (or the common value if a tie). We have previously found the joint and marginal distributions of and , displayed in the two-way table below.
\
1
2
3
4
2
1/16
0
0
0
1/16
3
0
2/16
0
0
2/16
4
0
1/16
2/16
0
3/16
5
0
0
2/16
2/16
4/16
6
0
0
1/16
2/16
3/16
7
0
0
0
2/16
2/16
8
0
0
0
1/16
1/16
1/16
3/16
5/16
7/16
Compute .
Construct a table, plot, and spinner to represent the conditional distribution of given .
Construct a table, plot, and spinner to represent the conditional distribution of given .
Construct a table, plot, and spinner to represent the conditional distribution of given .
Construct a table, plot, and spinner to represent the conditional distribution of given .
Compute .
Construct a table, plot, and spinner to represent the distribution of given .
Construct a table, plot, and spinner to represent the distribution of given .
Construct a table, plot, and spinner to represent the distribution of given .
The conditional distribution of given is the distribution of values over only those outcomes for which . It is a distribution on values of only; treat as a fixed constant when conditioning on the event .
Conditional distributions can be obtained from a joint distribution by slicing and renormalizing. The conditional distribution of given , where represents a particular number, can be thought of as:
the slice of the joint distribution corresponding to , a distribution on values of alone with fixed
renormalized so that the slice accounts for 100% of the probability over the values of
The shape of the conditional distribution of given is determined by the shape of the slice of the joint distribution over values of for the fixed .
For each fixed , the conditional distribution of given is a different distribution on values of the random variable . There is not one “conditional distribution of given ”, but rather a family of conditional distributions of given different values of .
Each conditional distribution is a distribution, so we can summarize its characteristics like mean and standard deviation. The conditional mean and standard deviation of given represent, respectively, the long run average and variability of values of over only pairs with .
Since each value of typically corresponds to a different conditional distribution of given , the conditional mean and standard deviation will typically be functions of .
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Warning: The `labeller` API has been updated. Labellers taking `variable` and `value`
arguments are now deprecated.
ℹ See labellers documentation.
Figure 14.1: Impulse plots representing the family of conditional distributions of given for the dice rolling example. Each plot represents a conditional distribution of given for a particular value of .
Figure 14.2: Spinners representing the family of conditional distributions of given in the dice rolling example. Each spinner represents a conditional distribution of given for a particular value of .
Example 14.2 We have already discussed two ways for simulating an pair in the dice rolling example: simulate a pair of rolls and measure (sum) and (max), or spin the joint distribution spinner for once.
Now describe another way for simulating an pair using the spinners in Example 14.1. (Hint: you’ll need one more spinner in addition to the four from the previous example.)
Describe in detail how you can simulate pairs and use the results to approximate .
Describe in detail how you can simulate pairs and use the results to approximate the conditional distribution of given .
Describe in detail how you can simulate values from the conditional distribution of given without simulating pairs.
Rather than directly simulating from a joint distribution, we can simulate an pair in two stages:
Simulate a value of from its marginal distribution. Call the simulated value .
Given , simulate a value of from the conditional distribution of given . There will be a different distribution (spinner) for each possible value of .
This “marginal then conditional” process is essentially implementing the multiplication rule
In many problems a joint distribution is nsturally described by specifying the marginal distribution of and the family of conditional distributions of given values of
(ref:cap-dice-mosaic) Mosaic plots for Example @ref(exm:dice-conditional), where is the sum and is the max of two rolls of a fair four-sided die. The plot on the left represents conditioning on values of the sum ; color represents values of . The plot on the right represents conditioning on values of the max ; color represents values of .
N_rep =16000# first roll u1 =sample(1:4, size = N_rep, replace =TRUE)# second rollu2 =sample(1:4, size = N_rep, replace =TRUE)# sumx = u1 + u2# maxy =pmax(u1, u2)
Warning: `unite_()` was deprecated in tidyr 1.2.0.
ℹ Please use `unite()` instead.
ℹ The deprecated feature was likely used in the ggmosaic package.
Please report the issue at <https://github.com/haleyjeppson/ggmosaic>.
Mosaic plot of conditional distributions of X given values of Y
Mosaic plot of conditional distributions of Y given values of X
Be sure to distinguish between joint, conditional, and marginal distributions.
The joint distribution of and is a distribution on pairs. A mathematical expression of a joint distribution is a function of both values of and values of .
The conditional distribution of given is a distribution on values (among pairs with a fixed value of ). A mathematical expression of a conditional distribution will involve both and , but is treated like a fixed constant and is treated as the variable. Note: the possible values of might depend on the value of .
The marginal distribution of is a distribution on values only, regardless of the value of . A mathematical expression of a marginal distribution will have only values of the single variable in it; for example, an expression for the marginal distribution of will only have in it (no , not even in the possible values).
Be careful when conditioning with continuous random variables. Remember that the probability that a continuous random variable is equal to a particular value is 0; that is, for continuous , . - Mathematically, when we condition on we are really conditioning on — the event that the random variable is within of the value — and seeing what happens in the idealized limit when .
Practically, represents our “close enough” degree of precision, e.g., if “within 0.01” is close enough.
When conditioning on a continuous random variable in a simulation, never condition on ; rather, condition on where represents the suitable degree of precision.
14.1 Conditional Expected Value
Example 14.3 Roll a fair four-sided die twice. Let be the sum of the two rolls, and let be the larger of the two rolls (or the common value if a tie).
\
1
2
3
4
2
1/16
0
0
0
1/16
3
0
2/16
0
0
2/16
4
0
1/16
2/16
0
3/16
5
0
0
2/16
2/16
4/16
6
0
0
1/16
2/16
3/16
7
0
0
0
2/16
2/16
8
0
0
0
1/16
1/16
1/16
3/16
5/16
7/16
Compute and interpret . How could you find a simulation-based approximation?
We have seen that the long run average value of is 3.125. Would you expect the conditional long run average value of given to be greater than, less than, or equal to 3.125? Explain without doing any calculations. What about given ?
How could you use simulation to approximate the conditional long run average value of given ?
Compute and interpret .
Find for each possible value of of .
Compute and interpret . How could you find a simulation-based approximation?
Find for each possible value of .
The conditional expected value (a.k.a. conditional expectation a.k.a. conditional mean), of a random variable given the event , defined on a probability space with measure , is a number denoted representing the probability-weighted average value of , where the weights are determined by the conditional distribution of given .
Remember, when conditioning on , is treated as a fixed constant. The conditional expected value is a number representing the mean of the conditional distribution of given .
The conditional expected value is the long run average value of over only those outcomes for which .
To approximate , simulate many pairs, discard the pairs for which , and average the values for the pairs that remain.