To understand the relation between two variables we must examine the conditional behavior of each of them given the value of the other. Towards this goal, we will start by examining the example of the previous section and then develop the general theory.
🎥 See More
In our example, the joint distribution of and is given by joint_table. Here we also display the marginal distribution of .
joint_table.marginal('X')Now suppose we know that . Then the outcome space is reduced to just the cells in the row labeled Y=3.
def indicator_Y_equals_3(i, j):
return j == 3
joint_table.event(indicator_Y_equals_3, 'X', 'Y')P(Event) = 0.3125
Of course, the probabilities along this row don’t sum to 1. Their sum is .
By the division rule, for each we have
By normalizing all the probabilities in the row by their sum, we get the conditional distribution of given .
Compare this conditional distribution to the unconditional distribution of :
The two distributions are different. Given , the chance that is large is higher than it is if we don’t have that condition.
This shows that and are dependent. We will define dependence and independence formally in the next section.
Answer
(a) 0.6
(b) 0 with chance 0.6, 1 with chance 0.4
(c) 2 with chance 1
4.4.1Conditional Distribution of given ¶
The conditional_dist method operates on a joint distribution object and displays conditional distributions, as follows.
# conditional distribution of X given each different value of Y
joint_table.conditional_dist('X', 'Y') To understand this table, start with the row labeled Y=3. The entries are the probabilities in the conditional distribution of given .
In the row labeled Y=1, the entries are the probabilities in the conditional distribution of given . Notice that if then can’t be 2. You can go back and confirm that in the joint distribution table, .
All the other rows can be understood in the same way. In row , the given condition is , and the entries are the probabilities in the conditional distribution of given .
It is easy to see why each row in the table of conditional distributions sums to 1. The value in each cell in the row is obtained from the joint distribution table by taking the corresponding cell in that table and dividing its entry by the sum of the entries in the row.
4.4.2The Theory¶
We can now generalize the calculations we did in the example above.
🎥 See More
Let and be two random variables defined on the same space. If is a possible value of , and and possible value of , then
The conditional probability is displayed in the cell of the table of conditional distributions above.
For a fixed value of , the conditional distribution of given is the collection of probabilities
where ranges over all the values of . Keep in mind that represents the values of the variable here. The value is the particular value of that was observed, so it is a constant.
4.4.3The Probabilities in a Conditional Distribution Sum to 1¶
In a distribution, the probabilities have to sum to 1. To see that this is true for the conditional distribution defined above, start by using the fundamental rule.
Find by partitioning the event according to the values of :
Now sum the probabilities in the conditional distribution of given :
Thus the conditional distribution is just an ordinary probability distribution: a set of values with probabilities that sum to 1.