掷骰子(Craps)

R 中的概率谜题

Peter Chi

Assistant Professor of Statistics Villanova University

Craps 简介

  • 通过线注(Pass line bet):一局开始时下的注
  • "射手"先掷

首掷:

  • 7 或 11:赢注
  • 2、3、12:输注
  • 其他点数:确立点(point)
R 中的概率谜题

确立点数后

Craps 桌面

  • 射手首掷:5 = 点数
  • 射手继续掷
  • 若在出7前先掷出5:通过线注赢
  • 若在出5前先掷出7:通过线注输
  • 直到掷出5 或 7 为止
R 中的概率谜题

while 循环

roll <- 0

while(roll != 6){
  roll <- roll_dice(1)
  print(roll)
}
5
2
5
6
R 中的概率谜题

while 循环中的复合条件

roll <- 0

while( (roll != 6) & (roll != 5) ){
  roll <- roll_dice(1)
  print(roll)
}
2
4
5
R 中的概率谜题

%in% 运算符

roll <- roll_dice(1)
if(roll %in% c(2,4,6) ){
  print("The roll is even")
}
"The roll is even"
roll
2
R 中的概率谜题

来玩一局 Craps!

R 中的概率谜题

Preparing Video For Download...