写了段模拟,结果大于16. 但我反倒觉得无穷才是对的。可能是随机seed,或者是数据长度定义有问题。求改错。
还可能是无穷方差的原因,无法有效模拟。
</p>
<p>profit <- function(ticket.price,N) {</p>
<p> profit <- 0 # profit of the seller.</p>
<p> for (i in 1:N) {<br />
count <- 0 # number of game performed till winning.</p>
<p> repeat {<br />
count <- count + 1<br />
if (sample(0:1,1) == 1) break<br />
}<br />
profit <- profit + ticket.price - 2^(count)<br />
}<br />
return(profit)<br />
}</p>
<p>## check if negative outcome possible<br />
repeat {<br />
result <- profit(100,10000)<br />
if (result <0) break<br />
}</p>
<p>## find break point<br />
for () {<br />
price <- price + 1<br />
if (profit(price,10000) >= 0 || price > 1000) break<br />
}<br />
price</p>
<p>
</p>