Sannolikhetspussel i R
Peter Chi
Assistant Professor of Statistics Villanova University
Varje "hand" dras från en Uniform(0,1)-fördelning.
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
Spelare B ser sitt värde och väljer om hen vill satsa 1 dollar eller inte
# Condition is true
x <- 4
result <- ifelse(x > 0, sqrt(x), sqrt(-x))
result
2
# Condition is false
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
Sannolikhetspussel i R