Kanspuzzels in R
Peter Chi
Assistant Professor of Statistics Villanova University
Elke “hand” getrokken uit een Uniform(0,1)-verdeling.
runif(n, min = 0, max = 1)runif(n = 1)
0.5888486
playerA <- runif(n = 1)
playerB <- runif(n = 1)
playerA > playerB
TRUE
playerA
0.6575921
playerB
0.3587836
Speler B ziet de waarde en besluit om $1 in te zetten of niet
# Voorwaarde is waar
x <- 4
result <- ifelse(x > 0, sqrt(x), sqrt(-x))
result
2
# Voorwaarde is onwaar
x <- (-4)
result <- ifelse(x > 0, sqrt(x), sqrt(-x))
result
2
values <- replicate(10, roll_dice(3))
values
5 10 14 5 12 12 4 15 7 9
mean(values)
9.3
Kanspuzzels in R