Independence Day
Part 1: Joint Distributions
Define a function independent_joint(pr_X, pr_Y)
that takes two
instances of DDist
as input. These DDist
inputs represent
distributions over independent random variables X and Y. Your
function should make use of make_joint_distribution
to return an
instance of DDist
representing the joint distribution \Pr(X,Y).
Enter your code for independent_joint
below. Assume that all the
classes and functions from lib601.dist
have been imported with:
from lib601.dist import *
Part 2: Sums
Assume that A and B are independent random variables with
integer support. Write a function independent_sum(pr_A, pr_B)
that takes as input two instances of DDist
, which represent the
distributions over A and B, respectively, and returns an instance
of DDist
representing the distribution over a new random variable
C, where C = A + B.
Enter your code for independent_sum
below. Assume that all the
classes and functions from lib601.dist
have been imported with:
from lib601.dist import *
and that a working definition of the independent_joint
function is
available.