3.7 Expected Value by Code
3.7.1 Expected Value of a Six-Sided Die
Let \(X\) represent the result of one roll of a 6 sided die.
- Build an object to represent the whole sample space, \(\Omega\) of a six sided die.
- Determine what probabilities to assign to each value of that object.
- Write the code to run the expectation algorithm that you just performed by hand.
3.7.2 Variance of a Six-Sided Die
Let \(X\) represent the result of one roll of a 6 sided die. Using what you know about the definition of variance, write a function that will compute the variance of your die
object.
Code
## [1] "fill this in"
Suppose that you had to keep the values the same on the die (that is the domain of the outcome still had to be the countable set of integers from one to six), but that you could modify the actual random process. Maybe you could sand off some of the corners on the die, or you could place weights on one side so that the side is less likely to come up. In this case, \(\omega \in \{1,2,3,4,5,6\}\), but you’re able to make a new \(f_{D}(d)\).
- How would you change the probability distribution to decrease the variance of this random variable?
- What is the smallest value that you can generate for this random variable? Use the
variance_function
from above to actually compute this variance. - What is the largest value of variance that you can generate for this random variable? Use the
variance_function
from above to actually compute this variance.
Now suppose that you again had an equal probability of every outcome, but you were to apply a function to the number of spots that are showing on the die. Rather that each dot contributing one value to the random variable, instead the random variable’s outcome is the square of the number of spots.
- How would this change the mean?
- How would this change the variance?