iPhone Passcodes

Probability Puzzles in R

Peter Chi

Assistant Professor of Statistics Villanova University

Unlocking an iPhone

iphone.png

Probability Puzzles in R

Four digits vs. three digits

Presh2.png

Presh1.png

 

Presh Talwalker: Mind Your Decisions

Probability Puzzles in R

The sample function

sample(x, size, replace = FALSE, prob = NULL)

 

From Monty Hall:

sample(doors,1)
three_values <- c(1,2,3)
sample(three_values)
3 1 2
Probability Puzzles in R

Sampling from repeated values

two_values <- c(1,2)
all_values <- c(two_values, sample(two_values,1))
all_values
1 2 2
sample(all_values)
2 2 1
Probability Puzzles in R

The identical function

set1 <- c(4,3,5)
set2 <- c(4,3,9)

set1 == set2
TRUE  TRUE FALSE

Two non-identical sets; FALSE returned:

identical(set1, set2)
FALSE

Two identical sets; TRUE returned:

set3 <- c(4,3,5)
identical(set1, set3)
TRUE
Probability Puzzles in R

Let's guess some iPhone passcodes!

Probability Puzzles in R

Preparing Video For Download...