## the other side of the dice

Posted in Books, Kids, pictures with tags , , , on August 19, 2022 by xi'an

A simple riddle from the Riddler: if a standard fair six-faced dice is falling on an edge rather than a face, what is the expectation of the sum of the faces sharing this edge?

The solution proposed there is however somewhat convoluted, when the average is simply

$\frac{1}{6}\sum_{i=1}^6 \{i+\frac{1+\cdots+6}{4}-\frac{i+7-i}{4}\}=7$

since the only face that does not share an edge with face i is 7-i…

## dice and sticks

Posted in Books, Kids, R with tags , , , , , , on November 19, 2021 by xi'an

A quick weekend riddle from the Riddler about the probability of getting a sequence of increasing numbers from dice with an increasing number of faces, eg 4-, 6-, and 8-face dice. Which happens to be 1/4. By sheer calculation (à la Gauss) or simple enumération (à la R):

> for(i in 1:4)for(j in (i+1):6)F=F+(8-j)
> F/4/6/8
[1] 0.25


The less-express riddle is an optimisation problem related with stick breaking: given a stick of length one, propose a fraction a and win (1-a) if a Uniform x is less than one. Since the gain is a(1-a) the maximal average gain is associated with a=½. Now, if the remaining stick (1-a) can be divided when x>a, what is the sequence of fractions one should use when the gain is the length of the remaining stick? With two attempts only, the optimal gain is still ¼. And a simulation experiment with three attempts again returns ¼.

## A discrete Bernoulli factory

Posted in Books, Kids, Statistics with tags , , , , , , on October 18, 2021 by xi'an

A rather confusing (and now closed) question on X validated contained an interesting challenge of simulating an arbitrary discrete distribution using a single (standard) dice. It indeed made me think of the (more challenging) Bernoulli factory problem of simulating B(f(p)) using a B(p) simulator (with p unknown). I still do not see what the optimal solution is but the core challenge is to avoid simulating U(0,1) variate by exploiting the discrete nature of the target. Which may be an issue if the probabilities of the target are irrational and one is considering the cdf inversion approach. An alternative is to use an accept-reject approach, which also works for discrete distributions, by first deriving an instrumental distribution on the discrete support of the target from dice rolls, second finding the maximum of the ratio instrument to target, and third devising a discrete approach to selecting a generation with a probability taking a finite number of values. Which may prove quite costly. Finally, the least debatable approach is to turn the dice into a Uniform generator by using each draw as a digit in the base 5 representation of this Uniform variate, up to the precision desired for the resolution, and then apply the most efficient algorithm for the target distribution.

## minimax, maximin or plain

Posted in Kids, R with tags , , , on June 1, 2020 by xi'an

A simple riddle from The Riddler on choosing between the maximum between two minima of two throws of an N-face dice, the minimum between two maxima of two throws of an N-face dice, and a single throw. Since maximin is always less than minimax, second choice is always worse than first and a stochastic domination version of the argument shows the single throw should stand in the middle.

## Le Monde puzzle [#847]

Posted in Books, Kids, R, Statistics with tags , , , on December 29, 2013 by xi'an

Another X’mas Le Monde mathematical puzzle:

A regular dice takes the values 4, 8 and 2 on three adjacent faces. Summit values are defined by the product of the three connected faces, e.g., 64 for the above. What values do the three other faces take if the sum of the eight summit values is 1768?

Here is the simple R code I used to find a solution:

summi=function(x){
#(x[1],x[2],x[3]) opposed to (4,8,2)
sum(outer(c(2,x[1]),outer(c(8,x[2]),c(4,x[3]),"*"),"*"))}
faces=matrix(sample(1:20,3*10^4,rep=T),ncol=3)
resum=apply(faces,1,summi)
sol=faces[resum==1768,]


with the result:

> sol
[,1] [,2] [,3]
[1,]    2   18   13
[2,]    2   18   13
[3,]    2   18   13
[4,]    6    5   13


which means the missing faces are (6,5,13) since the puzzle also imposed all faces were different. The following histogram of the sample of sums shows a reasonable gamma G(1.9,1763)  fit.