# Psycho dice and Monte Carlo

**Statisfaction » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Following Pierre’s post on *psycho dice*, I want here to see by which average margin repeated plays might be called *influenced by mind will*. The rules are the following (exerpt from the novel *Midnight in the Garden of Good and Evil*, by John Berendt):

You take four dice and call out four numbers between one and six–for example, a four, a three, and two sixes. Then you throw the dice, and if any of your numbers come up, you leave those dice standing on the board. You continue to roll the remaining dice until all the dice are sitting on the board, showing your set of numbers. You’re eliminated if you roll three times in succession without getting any of the numbers you need. The object is to get all four numbers in the fewest rolls.

Simplify the game by forgetting the elimination step. Suppose first one plays with an even dice of *1/p* faces. The probability of it to show the right face is *p* (for somebody with no *psy* power). Denote *X* the time to first success with one dice, which follows, by independence, a geometric distribution Geom(*p*) (with the starting-to-1 convention). *X* has the following probability mass and cumulative distribution functions, with *q=1-p*:

Now denote *Y* the time to success in the game with *n* dice. This simultaneous case is the same as playing *n* times independently with 1 dice, and then taking *Y* as the sample maximum of the different times to success. So *Y*‘s cdf is

Its pmf can be obtained either exactly by difference, or up to a normalizing constant *C* by differentiation:

As it is not too far from the Geom(*p*) pmf, one can use the latter as the proposal in a Monte Carlo estimate. If ‘s are *N* independent Geom(*p*) variables, then

and

The following R lines produce the estimates and .

p=1/6 q=1-p n=4 rgeom1=function(n,p){rgeom(n,p)+1} h=function(x){(1-q^x)^(n-1)} N=10^6 X=rgeom1(N,p) (C=1/mean(h(X))) (m1_Y=C*mean(X*h(X))) (m2_Y=C*mean(X^2*h(X))) (sd_Y=sqrt(m2_Y-m1_Y^2))

Now it is possible to use a test (from classical test theory) to estimate the average margin with which repeated games should deviate in order to detect statistical evidence of *psy* power. We are interested in testing against , for repeated plays.

If the game is played *k* times, then one rejects if the sampled mean is less than , where is the 95% standard normal quantile. To indicate the presence of a *psy* power, someone playing times should perform in 2 rolls less than the predicted value (in 1 roll less if playing times). I can’t wait, I’m going to grab a dice!

**leave a comment**for the author, please follow the link and comment on their blog:

**Statisfaction » R**.

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.