vignettes/selecting_right_coins_presentation.Rmd
selecting_right_coins_presentation.Rmd
Imagine that you have 50 pennies labeled 1 through 50 and you flip each one 10 times and write on each coin how many times it landed head side up.
I should have said, that we are looking for some lucky pennies, because I going to use the lucky pennies we find in a magic trick later. To find a lucky penny, I need to decide how many heads I need to observe to be surprised.
I am going to cheat, because I happen to remember just enough theoretical statistics to know that when you observe a group of boolean trials, you can use the binomial distribution to calculated the probability of observing any number of one type of observation (heads) out of a known number of trials. (We are not going to show the equation, but it’s a combinatorial expression with factorials so it is pretty.)
For the sake of brevity, I am going to tell you it takes a lot to surprise me.
## [1] 0.1171875
## [1] 0.04394531
## [1] 0.009765625
## [1] 0.0009765625
I am going to be a traditionalist here and decide I will be surprised if there are 8 or more heads out of 10 tosses.
## [1] 0.04394531
## [1] 4
## [1] 11 20 24 31
## [1] 8 8 9 8
Let’s examine what we have done and what we learned about these pennies through this experiment.
Now as statisticians, 10 is not a big enough sample for a good estimate so let’s make it bigger.
## [1] 2.049443e-86
## [1] 0.0006958708
## [1] 0.05337477
## [1] 0.04684365
surprise_threshhold_large <- 526
results_large <- rbinom(n_coins, tosses_large, p_heads)
dbinom(surprise_threshhold_large, tosses_large, p_heads)
## [1] 0.006531125
picks_large <- seq_along(results_large)[results_large >= surprise_threshhold_large]
length(picks_large)
## [1] 4
## [1] 5 15 26 39
## [1] 528 533 531 539