Sign Error Cancellations in a Math Problem

Probability Puzzles in R

Peter Chi

Assistant Professor of Statistics Villanova University

The inspiration

Probability Puzzles in R

The rbinom function

rbinom(n = 10, size = 5, prob = 0.4)
0 3 4 2 2 1 1 2 3 3
Probability Puzzles in R

Checking whether a value is even

value <- 3
value/2 == round(value/2)
FALSE

 

value <- 4
value/2 == round(value/2)
TRUE
Probability Puzzles in R

Using the mean function to estimate a probability

result <- c(TRUE, TRUE, FALSE, TRUE)
mean(result)
0.75
Probability Puzzles in R

Revisiting the sapply function

sapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
rbinom(n, size, prob)
result <- sapply(X = c(0.25, 0.75, 0.1, 0.9), FUN = rbinom, n = 1, size = 1)

result
0 1 0 1
sum(result)
2
Probability Puzzles in R

Let's do it!

Probability Puzzles in R

Preparing Video For Download...