- UID
- 1034461
- 在线时间
- 小时
- 注册时间
- 2014-8-7
- 最后登录
- 1970-1-1
- 主题
- 帖子
- 性别
- 保密
|
gamble <- function(bet.FUN, init.wealth=50, prob.win=0.52,mac.turns=25){
current.wealth <- init.wealth
bet <- bet.FUN(current.wealth,0)
games <- rbinom(mac.turns),1,prob.win
for( turn in 1:mac.turns){
if(games[turn]){
current.wealth current.wealth.wealth + bet
bet <- bet.FUN(current.wealth,bet)
} else {
current.wealth <- current.wealth - bet
bet <- bet.FUN(current.wealth, -bet)
}
if(current.wealth < 0 ) break
}
return(current.wealth - init.wealth)
}
|
|