ex5m4_4.doc

advertisement
Random Signals for Engineers using MATLAB and Mathcad
Copyright  1999 Springer Verlag NY
Example 4.4 Joint Discrete Expectation
 In this example we will compute the expectation of a discrete distribution functions whose
probability density function is respresented in a table below. A table of probabilities is constucted
where each entry corresponds to the P[ j heads and i number of tosses till a head occurs] in the the
first three tosses of a coin toss experiment.
P=[1/8 0 0 0;0 1/8 1/4 1/8;0 1/8 1/8 0;0 1/8 0 0 ]
P =
0.1250
0
0
0
0
0.1250
0.1250
0.1250
0
0.2500
0.1250
0
0
0.1250
0
0
The expected value for X and Y can be computed from the marginal distributions
PI=sum(P,2)'
PJ=sum(P,1)
PI =
0.1250
0.5000
0.2500
0.1250
0.1250
0.3750
0.3750
0.1250
PJ =
The expected values are E[J] =EJ and E[I]=EI
i=0:3;
EI=i*PI'
j=i;
EJ=j*PJ'
EI =
1.3750
EJ =
1.5000
and E[I2] = EI2 and E[J2] = EJ2
EI2= i.^2*PI'
EJ2=j.^2*PJ'
EI2 =
2.6250
EJ2 =
3
The two dimensional expectation are computed by the double summation as
v=i'*j
EIJ=sum(sum(v.*P))
v =
0
0
0
0
0
1
2
3
0
2
4
6
0
3
6
9
EIJ =
2.1250
and E[I+J] = EIPJ
si=[1;1;1;1]*i;
sj=j'*[1 1 1 1];
s=si+sj
EIPJ=sum(sum(s.*P))
s =
0
1
2
3
EIPJ =
2.8750
1
2
3
4
2
3
4
5
3
4
5
6
We should note that in general E[I + J ] = E[I] + E[J] because the expectation operator is
distributive.
The variance can be computed directly from the marginal summation or using the expresssion in
Equation 3.2-8. Similar relationship can be used for the covariance computations. VAR[I] = VARI
is=i-EI*ones(1,4)
VARI= is.^2*PI'
is =
-1.3750
VARI =
0.7344
-0.3750
0.6250
1.6250
or using Equation 3.2-8
EI2-EI^2
ans =
0.7344
Similarly for the J variable, VAR[J] =VARJ
js=j-EJ*ones(1,4)
VARJ= js.^2*PJ'
js =
-1.5000
-0.5000
0.5000
1.5000
VARJ =
0.7500
EJ2-EJ^2
ans =
0.7500
The covariance compuations proceeds in a similar manner, COV[IJ] = COVIJ
vs=is'*js
COVIJ= sum(sum(vs.*P))
vs =
2.0625
0.5625
-0.9375
-2.4375
COVIJ =
0.0625
0.6875
0.1875
-0.3125
-0.8125
-0.6875
-0.1875
0.3125
0.8125
-2.0625
-0.5625
0.9375
2.4375
EIJ-EI*EJ
ans =
0.0625
The correlation coefficient is therefore
rho =COVIJ/sqrt(VARJ)/sqrt(VARI)
rho =
0.0842
Two dimensional variance and covariances are often expressed as a matrix quantity and this is called
the covariance matrix P. For this example we have
 VARI
K 
COVIJ
COVIJ 
VARJ 
K=[VARI COVIJ;COVIJ VARJ]
K =
0.7344
0.0625
0.0625
0.7500

Download