Probability Puzzles in R
Peter Chi
Assistant Professor of Statistics Villanova University
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
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
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