Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
r=function()sample(0:1,1,p=c(d,m)) for(t in 1:1e6){ m=2;d=8 i=r();m=m-!!i;d=d-!i while(!!m*d){ j=r();i=ifelse(i==j,j,r()) m=m-!!i;d=d-!i} F=F+(m>0)} F/1e6
Now the proof that the probability is ½ is quite straightforward, for M=1 (or D=1). But I cannot find a quick fix for larger values. I thus reasoned by recursion, with the probability of emptying a given colour first is d!m!/(d+m)!, whatever the colour and whatever d>0,m>0. Hence half a chance to finish with myrtle. Any shorter sequence of a given colour reduces the value of either d or m, at which point we are using the recursion assumption that the probability is ½…
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.