Archive for Alice and Bob

Le Monde puzzle [#952]

Posted in Books, Kids, pictures, R, Statistics, Travel, University life with tags , , , on March 19, 2016 by xi'an

A quite simple Le Monde mathematical puzzle again with Alice and Bob:

In a multiple choice questionnaire with 50 questions, Alice gets a score s such that Bob can guess how many correct (+5 points), incorrect (-1 point) and missing (0 point) Alice got when adding that Alice could not have gotten s-2 or s+2. What is Alice’s score?

A first point is that the overall score is s=5c-i with c+i≤50.  Without further information, the possible results are all integers 0≤c≤50 such that c≥s/5 and 0≤i=s-5c≤50. Possible scores range from -50 to 250, but a quick R check shows that ten values are impossible

[sourcecode language=”r” gutter=”false”]
vales=rep(0,le=50+1+250)
for (c in 0:50){
for (i in 0:(50-c))vales[5*c-i+50+1]=1}
[/sourcecode]

which produces

[sourcecode language=”r” gutter=”false”]
> (1:length(vales))[vales==0]-50-1
[1] 231 236 237 241 242 243 246 247 248 249
[/sourcecode]

Thus looking at the differences, there is only one case for which s-2 and s+2 are impossible values, namely s=239. This means c=48, i=1 since c=49 leads to an impossible i.

 

Le Monde puzzle [#950]

Posted in Books, Kids, pictures, Statistics, Travel, University life with tags , , , , on March 10, 2016 by xi'an

A Le Monde mathematical puzzle with Alice and Bob:

Alice and Bob play a game with 100 tokens set in ten piles of 1, 9 piles of 2, 8 piles of 3, 7 piles of 4, and 4 piles of 5. They each take a token in turn, either to remove it from the game, or to create a new pile of one, provided this token is taken from a pile with at least two remaining tokens. The winner is the one left with the last token. If Alice starts, who is the winner?

I just wrote a most rudimentary recursive R function

[sourcecode language=”r” gutter=”false”]
reward=function(tokens){
gain=0
if (max(tokens)>0){
#takes one token off
for (i in (1:5)[tokens>0]){
gain=max(gain,1-reward(tokens-((1:5)==i)))
if (gain==1) break()}
#create another singleton
if (max(tokens[-1])>1){
for (i in (2:5)[tokens[-1]>1]){
gain=max(gain,1-reward(c(tokens[1]+1,tokens[-1]-((2:5)==i))))
if (gain==1) break()}}}
return(gain)}
[/sourcecode]

where token represents the number of remaining sets with 1, 2, 3, 4, and 5 tolkiens. With the suggested values, (10,18,24,28,20), the R code takes too long on my machine! Or even overnight on our server. So as usual I thought a bit more about it and started cutting at unnecessary bits, reaching the faster recursive function

[sourcecode language=”r” gutter=”false”]
reward=function(tokens){
#clean up piles with single token
tokens[1]=tokens[1]+sum((tokens[-1]==1))
tokens[-1][tokens[-1]==1]=0
if (max(tokens[-1])==0){
#end: no choice left
gain=1*(tokens[1]%%2==1)
}else{
gain=0
#all piles have to disappear, order should not matter
i=min((2:5)[tokens[-1]>1])
#set one token appart
gain=max(gain,1-reward(tokens-((1:5)==i)))
#create another singleton
gain=max(gain,1-reward(c(tokens[1]+1,tokens[-1]-((2:5)==i))))}
return(gain)}
[/sourcecode]

as all sets have to vanish at one point or another so order should not matter. However, with the starting values provided in the puzzle, two weeks of computation on our local cluster did produce nothing, as there are too many cases to examine! (The exact solution is that Alice cannot win the game if Bob plays in an optimal manner.)

a refutation of Johnson’s PNAS paper

Posted in Books, Statistics, University life with tags , , , , , , , on February 11, 2014 by xi'an

Jean-Christophe Mourrat recently arXived a paper “P-value tests and publication bias as causes for high rate of non-reproducible scientific results?”, intended as a rebuttal of Val Johnson’s PNAS paper. The arguments therein are not particularly compelling. (Just as ours’ may sound so to the author.)

“We do not discuss the validity of this [Bayesian] hypothesis here, but we explain in the supplementary material that if taken seriously, it leads to incoherent results, and should thus be avoided for practical purposes.”

The refutation is primarily argued as a rejection of the whole Bayesian perspective. (Although we argue Johnson’ perspective is not that Bayesian…) But the argument within the paper is much simpler: if the probability of rejection under the null is at most 5%, then the overall proportion of false positives is also at most 5% and not 20% as argued in Johnson…! Just as simple as this. Unfortunately, the author mixes conditional and unconditional, frequentist and Bayesian probability models. As well as conditioning upon the data and conditioning upon the rejection region… Read at your own risk. Continue reading →