Le Monde puzzle [#905]

Posted in Books, Kids, R, Statistics, University life with tags , , , on April 1, 2015 by xi'an

A recursive programming  Le Monde mathematical puzzle:

Given n tokens with 10≤n≤25, Alice and Bob play the following game: the first player draws an integer1≤m≤6 at random. This player can then take 1≤r≤min(2m,n) tokens. The next player is then free to take 1≤s≤min(2r,n-r) tokens. The player taking the last tokens is the winner. There is a winning strategy for Alice if she starts with m=3 and if Bob starts with m=2. Deduce the value of n.

Although I first wrote a brute force version of the following code, a moderate amount of thinking leads to conclude that the person given n remaining token and an adversary choice of m tokens such that 2m≥n always win by taking the n remaining tokens:

optim=function(n,m){

outcome=(n<2*m+1)
if (n>2*m){
for (i in 1:(2*m))
outcome=max(outcome,1-optim(n-i,i))
}
return(outcome)
}


eliminating solutions which dividers are not solutions themselves:

sol=lowa=plura[plura<100]
for (i in 3:6){
sli=plura[(plura>10^(i-1))&(plura<10^i)]
ace=sli-10^(i-1)*(sli%/%10^(i-1))
lowa=sli[apply(outer(ace,lowa,FUN="=="),
1,max)==1]
lowa=sort(unique(lowa))
sol=c(sol,lowa)}


> subs=rep(0,16)
> for (n in 10:25) subs[n-9]=optim(n,3)
> for (n in 10:25) if (subs[n-9]==1) subs[n-9]=1-optim(n,2)
> subs
[1] 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
> (10:25)[subs==1]
[1] 18


Ergo, the number of tokens is 18!

MCMskv, Lenzerheide, Jan. 5-7, 2016

Posted in Mountains, Kids, Statistics, University life, Travel, pictures, R with tags , , , , , , , , , , , , , , , , on March 31, 2015 by xi'an

Following the highly successful [authorised opinion!, from objective sources] MCMski IV, in Chamonix last year, the BayesComp section of ISBA has decided in favour of a two-year period, which means the great item of news that next year we will meet again for MCMski V [or MCMskv for short], this time on the snowy slopes of the Swiss town of Lenzerheide, south of Zürich. The committees are headed by the indefatigable Antonietta Mira and Mark Girolami. The plenary speakers have already been contacted and Steve Scott (Google), Steve Fienberg (CMU), David Dunson (Duke), Krys Latuszynski (Warwick), and Tony Lelièvre (Mines, Paris), have agreed to talk. Similarly, the nine invited sessions have been selected and will include Hamiltonian Monte Carlo,  Algorithms for Intractable Problems (ABC included!), Theory of (Ultra)High-Dimensional Bayesian Computation, Bayesian NonParametrics, Bayesian Econometrics,  Quasi Monte Carlo, Statistics of Deep Learning, Uncertainty Quantification in Mathematical Models, and Biostatistics. There will be afternoon tutorials, including a practical session from the Stan team, tutorials for which call is open, poster sessions, a conference dinner at which we will be entertained by the unstoppable Imposteriors. The Richard Tweedie ski race is back as well, with a pair of Blossom skis for the winner!

As in Chamonix, there will be parallel sessions and hence the scientific committee has issued a call for proposals to organise contributed sessions, tutorials and the presentation of posters on particularly timely and exciting areas of research relevant and of current interest to Bayesian Computation. All proposals should be sent to Mark Girolami directly by May the 4th (be with him!).

also sprach Nietzsche

Posted in Books, Kids, pictures with tags , , , , , , on March 30, 2015 by xi'an

intuition beyond a Beta property

Posted in Books, Kids, R, Statistics, University life with tags , , , on March 30, 2015 by xi'an

A self-study question on X validated exposed an interesting property of the Beta distribution:

If x is B(n,m) and y is B(n+½,m) then √xy is B(2n,2m)

While this can presumably be established by a mere change of variables, I could not carry the derivation till the end and used instead the moment generating function E[(XY)s/2] since it naturally leads to ratios of B(a,b) functions and to nice cancellations thanks to the ½ in some Gamma functions [and this was the solution proposed on X validated]. However, I wonder at a more fundamental derivation of the property that would stem from a statistical reasoning… Trying with the ratio of Gamma random variables did not work. And the connection with order statistics does not apply because of the ½. Any idea?

Posted in Books, Kids, Statistics with tags , , , , , , , on March 26, 2015 by xi'an

Cristiano Villa and Stephen Walker arXived on last Friday a paper entitled On the mathematics of the Jeffreys-Lindley paradox. Following the philosophical papers of last year, by Ari Spanos, Jan Sprenger, Guillaume Rochefort-Maranda, and myself, this provides a more statistical view on the paradox. Or “paradox”… Even though I strongly disagree with the conclusion, namely that a finite (prior) variance σ² should be used in the Gaussian prior. And fall back on classical Type I and Type II errors. So, in that sense, the authors avoid the Jeffreys-Lindley paradox altogether!

The argument against considering a limiting value for the posterior probability is that it converges to 0, 21, or an intermediate value. In the first two cases it is useless. In the medium case. achieved when the prior probability of the null and alternative hypotheses depend on variance σ². While I do not want to argue in favour of my 1993 solution

$\rho(\sigma) = 1\big/ 1+\sqrt{2\pi}\sigma$

since it is ill-defined in measure theoretic terms, I do not buy the coherence argument that, since this prior probability converges to zero when σ² goes to infinity, the posterior probability should also go to zero. In the limit, probabilistic reasoning fails since the prior under the alternative is a measure not a probability distribution… We should thus abstain from over-interpreting improper priors. (A sin sometimes committed by Jeffreys himself in his book!)

Le Monde puzzle [#904.5]

Posted in Books, Kids, R, Statistics, University life with tags , , , on March 25, 2015 by xi'an

Find all plural integers, namely positive integers such that (a) none of their digits is zero and (b) removing their leftmost digit produces a dividing plural integer (with the convention that one digit integers are all plural).

a slight modification in the R code allows for a faster exploration, based on the fact that solutions add one extra digit to solutions with one less digit:

First, I found this function on Stack Overflow to turn an integer into its digits:

pluri=plura=NULL
#solutions with two digits
for (i in 11:99){

dive=rev(digin(i)[-1])
if (min(dive)&gt;0){
dive=sum(dive*10^(0:(length(dive)-1)))
if (i==((i%/%dive)*dive))
pluri=c(pluri,i)}}

for (n in 2:6){ #number of digits
plura=c(plura,pluri)
pluro=NULL
for (j in pluri){

for (k in (1:9)*10^n){
x=k+j
if (x==(x%/%j)*j)
pluro=c(pluro,x)}
}
pluri=pluro}


which leads to the same output

&gt; sort(plura)
[1] 11 12 15 21 22 24 25 31 32 33 35 36
[13] 41 42 44 45 48 51 52 55 61 62 63 64
[25] 65 66 71 72 75 77 81 82 84 85 88 91
[37] 92 93 95 96 99 125 225 312 315 325 375 425
[49] 525 612 615 624 625 675 725 735 825 832 912
[61] 915 925 936 945 975 1125 2125 3125 3375 4125
[70] 5125 5625
[72] 6125 6375 7125 8125 9125 9225 9375 53125
[80] 91125 95625


Le Monde puzzle [#904]

Posted in Books, Kids, Statistics, University life with tags , , on March 25, 2015 by xi'an

An arithmetics Le Monde mathematical puzzle:

Find all plural integers, namely positive integers such that (a) none of their digits is zero and (b) removing their leftmost digit produces a dividing plural integer (with the convention that one digit integers are all plural).

An easy arithmetic puzzle, with no real need for an R code since it is straightforward to deduce the solutions. Still, to keep up with tradition, here it is!

First, I found this function on Stack Overflow to turn an integer into its digits:

digin=function(n){
as.numeric(strsplit(as.character(n),"")[[1]])}


then I simply checked all integers up to 10⁶:

plura=NULL
for (i in 11:10^6){
dive=rev(digin(i)[-1])
if (min(dive)>0){
dive=sum(dive*10^(0:(length(dive)-1)))
if (i==((i%/%dive)*dive))
plura=c(plura,i)}}


eliminating solutions which dividers are not solutions themselves:

sol=lowa=plura[plura<100]
for (i in 3:6){
sli=plura[(plura>10^(i-1))&(plura<10^i)]
ace=sli-10^(i-1)*(sli%/%10^(i-1))
lowa=sli[apply(outer(ace,lowa,FUN="=="),
1,max)==1]
lowa=sort(unique(lowa))
sol=c(sol,lowa)}


> sol
[1] 11 12 15 21 22 24 25 31 32 33 35 36
[13] 41 42 44 45 48 51 52 55 61 62 63 64
[25] 65 66 71 72 75 77 81 82 84 85 88 91
[37] 92 93 95 96 99 125 225 312 315 325 375 425
[49] 525 612 615 624 625 675 725 735 825 832 912
[61] 915 925 936 945 975 1125 2125 3125 3375 4125
[70] 5125 5625
[72] 6125 6375 7125 8125 9125 9225 9375 53125
[80] 91125 95625


leading to the conclusion there is no solution beyond 95625.