Introduction to Statistics in R
Maggie Matsui
Content Developer, DataCamp
Expected value: mean of a probability distribution
Expected value of a fair die roll = $(1 \times \frac{1}{6}) + (2 \times \frac{1}{6}) +(3 \times \frac{1}{6}) +(4 \times \frac{1}{6}) +(5 \times \frac{1}{6}) +(6 \times \frac{1}{6}) = 3.5$
$$P(\text{die roll}) \le 2 = ~?$$
$$P(\text{die roll}) \le 2 = 1/3$$
Expected value of uneven die roll = $(1 \times \frac{1}{6}) +(2 \times 0) +(3 \times \frac{1}{3}) +(4 \times \frac{1}{6}) +(5 \times \frac{1}{6}) +(6 \times \frac{1}{6}) = 3.67$
$$P(\text{uneven die roll}) \le 2 = ~?$$
$$P(\text{uneven die roll}) \le 2 = 1/6$$
Describe probabilities for discrete outcomes
Discrete uniform distribution
die
n
1 1
2 2
3 3
4 4
5 5
6 6
mean(die$n)
3.5
rolls_10 <- die %>%
sample_n(10, replace = TRUE)
rolls_10
n
1 1
2 1
3 5
4 2
5 1
6 1
7 6
8 6
...
ggplot(rolls_10, aes(n)) +
geom_histogram(bins = 6)
mean(rolls_10$n)
= 3.0
mean(die$n)
= 3.5
mean(rolls_100$n)
= 3.36
mean(die$n)
= 3.5
mean(rolls_1000$n)
= 3.53
mean(die$n)
= 3.5
As the size of your sample increases, the sample mean will approach the expected value.
Sample size | Mean |
---|---|
10 | 3.00 |
100 | 3.36 |
1000 | 3.53 |
Introduction to Statistics in R