โมเดลฟอน นอยมันน์

Probability Puzzles in 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
Probability Puzzles in R

การเดิมพันในโมเดลฟอน นอยมันน์

ผู้เล่น B ดูค่าที่ได้แล้วตัดสินใจว่าจะวางเดิมพัน $1 หรือไม่

  • ถ้าวางเดิมพัน: เปรียบเทียบค่าของทั้งสองฝ่าย ผู้ที่ค่าสูงกว่าชนะเงิน $1 จากอีกฝ่าย
  • ถ้าไม่วางเดิมพัน: ไม่มีฝ่ายใดได้หรือเสียเงิน
Probability Puzzles in R

ฟังก์ชัน ifelse

# 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
Probability Puzzles in R

ฟังก์ชัน mean อีกครั้ง

values <- replicate(10, roll_dice(3))
values
5 10 14  5 12 12  4 15  7  9

 

mean(values)
9.3
Probability Puzzles in R

ถึงคิวของคุณแล้ว!

Probability Puzzles in R

Preparing Video For Download...