Ймовірнісні головоломки в R
Peter Chi
Assistant Professor of Statistics Villanova University
Кожна «рука» вибирається з розподілу Uniform(0,1).
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
Гравець B бачить значення і вирішує, чи робити ставку $1
# Умова істинна
x <- 4
result <- ifelse(x > 0, sqrt(x), sqrt(-x))
result
2
# Умова хибна
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
Ймовірнісні головоломки в R