Expectations, Trials, and Outcomes
What is the expected value?
For random variables, we often cannot predict with certainty the answer. We can measure how likely events are too happen and calculate an expected answer. We are going to perform a series of simple experiments. For each, you will roll the dice (die) 10 times and mark the sum with an 'X'. Also, enter your average value for each.
Histogram for a 12sided die 




































1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
Histogram for sum of 2 6sided dice 




































1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
Histogram for sum of a 4sided & 8sided dice 




































1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
 What is the average (mean) value of each?
 Are the average values the same? Why or why not? Should they be? Explain your intuition.
Expectations
Assuming all the dice are fair, we can easily calculate the expected value of a roll. Let X be the value we roll for a 12sided die. Let Pr[X = 1] be the probability that we roll a '1', Pr[X = 2] be the probability we roll a '2', etc. We can calculate our expected value by weighting each value by its probability of occurring:
E[X] = 1*(probability of rolling 1) + 2*(probability of rolling 2) + ... + 12*(probability of rolling 12)
= 1*Pr[X = 1] + 2*Pr[X = 2] + ... + 12*Pr[X = 12]
= 1 * 1/12 + 2 * 1/12 + ... + 12 * 1/12
= 13*6/12 = 13/2 = 6.5
What happens if we have 2 6sided dice? How many ways can we roll each value?
sum 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
ways 
none 
1+1 
1+2 
1+3 










2+1 
2+2 











3+1 












































Prob: 
0 
1/36 
2/36 
3/36 








What happens if we have a 4sided and 8sided dice? How many ways can we roll each value?
sum 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
ways 
none 
1+1 
1+2 
1+3 
1+4 
1+5 








2+1 
2+2 
2+3 
2+4 









3+1 
3+2 
3+3 










4+1 
4+2 






Prob: 
0 
1/32 
2/32 
3/32 








The probability of rolling i and then j (to get i+j) is 1/4 * 1/8 = 1/32. What is the expected value?
What happens if we have 3 4sided dice?
 How many ways can we roll each value?
 The probability of rolling first i, then j, and then k (to get i+j+k) is 1/4 * 1/4 * 1/4 = 1/64. What is the expected value?
For which set of dice, would you expect the highest value rolled? Why?
Using Python to Model Rolling Dice:
Try the Python program,
randomRoll.py that simulates rolling dice and calculates the average value of the simulation and expected value.
Challenges:
If time, here are some challenges based on the Python program:
 Modify the program to simulate 100 rolls, then 1000 rolls, and finally 10,000 rolls. What happens to the average value of the simulation?
 Modify the program to simulate rolling two 12sided dice for 10 rolls.
 How close is the average of the simulation to the expected value? Does it improve if you do 100 rolls? Why?