Math 1180 - Mathematics for Life Scientists

advertisement
Math 1180 - Mathematics for Life Scientists
Lab 5 - Joint and Marginal Distribution
Due Tuesday, March 13, 2006
Getting Started
As usual, create a directory for lab 5 by typing mkdir
fresh.
lab5.
Open Maple and type restart; to start
Problems
1. Consider the following joint probability distribution.
S2 = 2
S2 = 4
S1 = 1 S1 = 3
0.3
0.2
0.0
0.5
We can enter it into Maple with the commands
> v := [[1,2],[1,4],[3,2],[3,4]];
> p := [0.3,0.2,0.0,0.5];
The values are hidden as follows: v[1][2] is the second component of the rst entry ([1,2]) in the
list v, i.e. the value 2. Experiment with this until it makes sense. We will use the sum command
in various ways today. As an example, to nd the mean of S1 , you could type,
> meanS1 := sum(v[k][1]*p[k],k=1..4);
This does the following:
meanS1 = v[1][1] p[1] + v[2][1] p[2] + v[3][1] p[3] + v[4][1] p[4]
= 1 0:3 + 1 0:2 + 3 0:0 + 3 0:5
= 2:
To nd the marginal distribution for S1 , you would use the commands:
>
>
>
>
margS1eq1:=p[1]+p[2];
margS1eq3:=p[3]+p[4];
v1:=[1,3];
m1:=[margS1eq1,margS1eq3];
This gives the sum of each column, margS1eq1=Pr(S1 = 1) and margS1eq3=Pr(S1 = 3), and
places them in a list m1. v1 holds the possible values of S 1. These can then be used to nd the
expectation as follows:
> meanS1:=sum(v1[k]*m1[k],k=1..2);
This mean should match the one found previously with a single command. Use these ideas to do
the following exercises. (You do not need to rend the marginal distributions every time. After
part a, simply use v1, m1, v2, m2, v, and p when appropriate.)
(a) Find the mean of S2 .
(b) Find the variances of S1 and S2 . (Recall, var(X ) = E (X 2 ) [E (X )]2 .)
(c) Find the covariance of S1 and S2 . (Recall, cov(X; Y ) = E (XY ) E (X )E (Y ).)
cov(X;Y ) where X =
(d) Find
the
correlation
of
S
(Recall,
correlation
1 and S2 .
X;Y =
pvar(X ). The command for square root in Maple is sqrt(stu); X Y
2. Suppose we have two random variable X and Y where
Y =5 X +B
where B is a Bernoulli random variable taking on the value 1 with probability 0.5. Suppose that
X takes on the values 1, 2, 3 and 4 each with probability 0.25. Assume X and B are independent.
Input this information as follows:
>
>
>
>
B:=[0,1];
pB:=0.5;
X:=[1,2,3,4];
pX:=0.25;
(a) Find the means of X and B .
(b) By hand, nd what values Y can take on. If necessary, draw a table listing the possible X
and B values to help you.
(c) By hand, nd the marginal distribution for Y (i.e., nd Pr(Y=1), Pr(Y=2), etc.). Then,
input this into Maple and use it to nd the mean and standard deviation of Y .
(d) Use the means of X and B and properties of expectations to show that E (5 X + B ) equals
the mean of Y that you just found.
Download