# Dice by stariya

VIEWS: 5 PAGES: 8

• pg 1
```									Calculating expected value, variance, and covariance from a sample (empirical data)
Objectives:
 Practice calculating mean, variance, and covariance.
 Become more familiar with math symbols.
 Better understand the meaning of covariance.

Note that individual answers (observations) are recorded in boxes and class answers (summary statistics) are recorded in circles.

Step 1. Roll your die. Define X = the result of the first die roll (1-6)

Step 2. Roll your die a second time. Define Y = the sum of both rolls (2-12)

Step 3. We will calculate the sample mean of X and the sample mean of Y as a class. (Follow along to make sure you understand how
the calculation is being made). Record these below:

n

X
i 1
i
Sample mean of X: X n                           =
n
n

Y
i 1
i
Sample mean of Y: Yn                        =
n

Step 4: Calculate the squared deviation of your X and Y observations from the group means:

record your ( X i  X n ) here:
2

record your (Yi  Yn ) here:
2

Step 5. We will calculate the sample variance of X and the sample variance of Y as a class. (Follow along to make sure you
understand how the calculation is being made). Record these below:

n

(X
i 1
i     X n )2
Sample variance of X: s x 
2
=
n 1
n

 (Y
i 1
i        Yn ) 2
Sample variance of Y: s y 
2
=
n 1

Step 6. Calculate the product of X and Y deviations:

record your ( Yi  Yn )( X i  X n ) here:

Step 6. We will calculate the sample covariance of X and Y. (Follow along to make sure you understand how the calculation is being
n

 (Y
i 1
i    Yn )( X i  X n )
Sample covariance of X and Y: s x , y                                                            =
n 1
For class discussion: What do you note about the relationship between variance and covariance here? How
does this make sense intuitively?

RECORD CLASS OBSERVATIONS HERE.

Observation      Xi                Yi               (X i  X n )2      (Yi  Yn ) 2      ( Yi  Yn )( X i  X n )

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15
Calculating expected value, variance, and covariance of a random variable with a known (a priori) probability
distribution:

Mean (expected value):   E ( x)               x p(x )
all x
i          i

Variance:  x 2  Var ( x)  E ( x   x ) 2           [x
all x
i     x ] 2 p( xi )  algebra  E ( x 2 )   x  E ( x 2 )  E ( x) 2
2

Covariance:
 xy  Cov ( xy )  E[( x   x )( y   y )]          (x
all x i , y i
i         x )( y i   y ) p( xi & y i )  algebra

 E ( xy )   x  y  E ( xy )  E ( x) E ( y )

The covariance of two random variables measures their tendency to vary together, i.e., to co-vary. Where the
variance is the average squared deviation of a random variable from its mean, the covariance is the average of
the products of the deviations of two random values from their respective means.
In-Class Exercise:
A Priori version of the dice problem:

Fill in the following joint probabilities, P(X&Y)

As before,
X = the result of the first die roll
Y = sum of both rolls
X

1           2             3         4   5   6

1        P(X=1&Y=1)=0   P(X=2&Y=1)=0   P(X=3&Y=1)=0

2         P(X=1&Y=2)=   P(X=2&Y=2)=0
1/36
3

4

5
Y                         6

7

8

9

10

11

12
Next, using the above joint probability table,
Calculate the a priori means of X and Y, variances of X and Y, and covariance of X and Y.

X          Marginal probability table:
x        x2         p(x)
1        1     p(x=1)=1/6
2        4     p(x=2)=1/6
3        9     p(x=3)=1/6
4       16     p(x=4)=1/6
5       25     p(x=5)=1/6
6       36     p(x=6)=1/6
1.0
E(x) =

E(x2) =

 x 2 =Var(x) = E(x2) – [E(x)]2 =
Y
Marginal probability table:
y        y2          p(y)
1         1            0
2         4          1/36
3         9          2/36
4        16          3/36
5        25          4/36
6        36          5/36
7        49          6/36
8        64          5/36
9        81          4/36
10       100          3/36
11       121          2/36
12       144          1/36

E(y) =

E(y2)=

 y 2 =Var(y) = E(y2) – [E(y)]2 =

E(xy) = (refer to joint probability table)

Cov(xy) = E(xy) – [E(x)][E(y)] =

X

1      2      3      4      5      6
1     0      0      0      0      0      0
2    1/36    0      0      0      0      0
3    1/36   1/36    0      0      0      0
4    1/36   1/36   1/36    0      0      0
5    1/36   1/36   1/36   1/36    0      0
Y
6    1/36   1/36   1/36   1/36   1/36    0
7    1/36   1/36   1/36   1/36   1/36   1/36
8     0     1/36   1/36   1/36   1/36   1/36
9     0      0     1/36   1/36   1/36   1/36
10    0      0      0     1/36   1/36   1/36
11    0      0      0      0     1/36   1/36
12    0      0      0      0      0     1/36
X

x                  x2          p(x)
1                   1      p(x=1)=1/6
2                   4      p(x=2)=1/6
3                   9      p(x=3)=1/6
4                  16      p(x=4)=1/6
5                  25      p(x=5)=1/6
6                  36      p(x=6)=1/6
1.0

 x p(x )  (1)( 6 )  2( 6 )  3( 6 )  4( 6 )  5( 6 )  6( 6 ) 
1       1      1       1   21  1      1
E(x) =                      i     i                                       3.5
all x                                                         6


1      1      1       1       1       1
E(x2) =        xi p(x i )  (1)( )  4( )  9( )  16( )  25( )  36( )  15.16666
2

all x                  6      6      6       6       6       6

 x 2 =Var(x) = E(x2) – [E(x)]2 = 15 - (3.5)2 = 2.916666

Y
Marginal probability table:
y        y2          p(y)
1         1            0
2         4          1/36
3         9          2/36
4        16          3/36
5        25          4/36
6        36          5/36
7        49          6/36
8        64          5/36
9        81          4/36
10       100          3/36
11       121          2/36
12       144          1/36

 y p(y
1
E(y) =             i        i   )(         )[ 2(1)  3(2)  4(3)  5(4)  6(5)  7(6)  8(5)  9(4)  10(3)  11(2)  12(1)]  7.0
all y                          36

E(y )=  y i 2 p(y i )  1 [4(1)  9(2)  16(3)  25(4)  36(5)  49(6)  64(5)  81(4)  100(3)  121(2)  144(1)]  54.833
2

all y                   36

 y =Var(y) = E(y ) – [E(y)]2 = 54.8333-49 = 5.83333
2                             2

Notice: the expected value and variance are exactly twice that of those for X!!
Covariance of X and Y:

1         2         3          4         5         6
1         0         0         0          0         0         0
2       1/36        0         0          0         0         0
3       1/36      1/36        0          0         0         0
4       1/36      1/36      1/36         0         0         0
5       1/36      1/36      1/36       1/36        0         0
6       1/36      1/36      1/36       1/36      1/36        0
7       1/36      1/36      1/36       1/36      1/36      1/36
8         0       1/36      1/36       1/36      1/36      1/36
9         0         0       1/36       1/36      1/36      1/36
10         0         0         0        1/36      1/36      1/36
11         0         0         0          0       1/36      1/36
12         0         0         0          0         0       1/36

 x y p(x
1
i , yi   )      [2  3  4  5  6  7  6  8  10  12  14  16  12  15  18  21  24  27  20 
E(xy) =   all x, y
i i
36
24  28  32  36  40  30  35  40  45  50  55  42  48  54  60  66  72]  987 / 36  27.41666

Cov(xy) = 27.41666 – (3.5) (7.0) = 2.91666

Notice: Covariance of X and Y = Variance of X (they share completely the variance of X).

```
To top