Lab 3 handouts
From SeedWiki
Student Name ___________________________ Student ID ___________________________________
Lab 3: Independence and Identical Distribution
This handout is available at http://seed.ucsd.edu/mediawiki/index.php/Lab_3_handouts. You can also go there from course webpage: Course Web Page -> Handouts -> Lab 3 Handout
This lab is about distribution and independence. Download matlab files Lab3_1.m,Lab3_2.m,Lab3_3.m
Notation: I'll use
to represent P(Xi = j).
Single Random Variable Distribution
We generate 1000 samples of random variable X. X takes on values -1,0,1 with probability 0.2, 0.7 and 0.1. Code is in matlab file Lab3_1.m
- Calculate the mean, variance and std-dev of X
- A:
- Estimate the mean, variance and std-dev using the 1000 samples that we generated. Do the estimates match the calculated value?
- A:
- Use the samples to estimate the distribution i.e., find P(X = i) for i = − 1,0,1
- A:
Two Random Variables: Distribution and Independence
Code for this part is in matlab file Lab3_2.m
We generate 1000 samples of random variables X1 and X2 which can take values 0 or 1. They are independent and identically distributed:
and
for both i = 1,2.
- From the sample, estimate
for i = 1,2 and j = 0,1. Find the mean, variance, std-dev of X1 and X2.
- A:
- What should be the co-variance of X1 and X2 based on your understanding? Find the co-variance for the sample that you have.
- A:
- Estimate the joint distribution of P(X1,X2). From these estimates, do you think that the random variables are independent?
- A:
Now generate 1000 samples of random variables X1 and X2.
For X1,
. For X2, p(X2 = 1 | X1 = 1) = 0.7, p(X2 = 0 | X1 = 1) = 0.3, p(X2 = 1 | X1 = 0) = 0.3, p(X2 = 0 | X1 = 0) = 0.7.
- Find the co-variance of X1 and X2.
- A:
- From the co-variance of X1 and X2, do you think X1 and X2 are independent?
- A:
- Estimate the joint distribution of P(X1,X2). Do these estimates suggest that X1 and X2 are independent?
- A:
- Is it always possible to estimate the joint distribution with sufficient accuracy? Think about the number of values the random variables can take.
- A:
Multiple Random Variable Independence
In the above example we were just judging independence between only 2 random variables. We now move to independence of more than 2 variables.
Code for this part is matlab file Lab3_3.m
Now we generate 10000 samples of 3 random variables X1, X2 and X3. X1 and X2 are independent and identically distributed with
for both i = 1,2. X3 is generated by flipping X2 if X1 is 1.
- Is X3 independent of X1? Is X3 independent of X2? Find it out by estimating the joint probabilities.
- A:
- Are X1, X2 and X3 mutually independent i.e., is P(X1 = i,X2 = j,X3 = k) = P(X1 = i) * P(X2 = j) * P(X3 = k) for all values of i,j and k? Try to answer it based on your understanding.
- A:
- Find the joint probability distribution of P(X1 = i,X2 = j,X3 = k) for all possible combination's of i,j and k. Does it suggest that X1,X2andX3 are independent?
- A: