Archive for The Riddler

more breaking sticks

Posted in Statistics with tags , , on July 19, 2021 by xi'an

A quick riddle from The Riddler that, when thinned to the actual maths problem, ends up asking for

\mathbb P(\max(U_1,U_2,U_3)=U_3)+\mathbb P(\min(U_1,U_2,U_3)=U_3)

which is equal to 2/3…. Anticlimactic.

multinomial but unique

Posted in Kids, R, Statistics with tags , , , , , , on July 16, 2021 by xi'an

A quick riddle from the Riddler, where the multinomial M(n¹,n²,100-n¹-n²) probability of getting three different labels out of three possible ones out of three draws is 20%, inducing a single possible value for (n¹,n²) up to a permutation.

Since this probability is n¹n²(100-n¹-n²)/161,700, there indeed happens to be only one decomposition of 32,340 as 21 x 35 x 44. The number of possible values for the probability is actually 796, with potential large gaps between successive values of n¹n²(100-n¹-n²) as shown by the above picture.

almost reversed 2-lag Markov chain

Posted in Kids, R, Statistics with tags , , , , on July 7, 2021 by xi'an

Another simple riddle from the Riddler: take a binary sequence and associate to this sequence a score vector made of the numbers of consecutive ones from each position. If the sequence is ten step long and there are 3 ones located at random, what is the expected total score? (The original story is much more complex and involves as often strange sports!)

Adding two zeroes at time 11 and 12, this is quite simple to code, e.g.

f=0*(1:10) #frequencies
for(v in 1:1e6){
 r=0*f#reward
 s=sample(1:10,3)
 for(t in s)r[t]=1+((t+1)%in%s)*(1+((t+2)%in%s))
 f[sum(r)]=f[sum(r)]+1}
f=f/1e6

and the outcome recovers the feature that the only possible scores are 1+1+1=3 (all ones separated), 1+1+2=4 (two ones contiguous),  and 1+2+3=6 (all ones contiguous). With respective frequencies 56/120, 56/120, and 8/120. With 120 being the number of possible locations of the 3 ones.

breaking sticks of various length

Posted in Kids, pictures, R with tags , , , , on July 6, 2021 by xi'an

A riddle from the Riddler with a variation on the theme of breaking sticks: Given a stick of length L, what is the optimal manner to break said stick to achieve a maximal product of the individual lengths? While the pen & paper resolution is a one-line back-of-the-envelope calculation, with an impact of the length L, obviously,  a quick R code leads to an approximate solution:

mw=function(k=2,l=10,T=1e6){
  a=matrix(runif(T*k),k)
  for(i in 1:T)F=max(F,prod(l*a[,i]/sum(a[,i])))
  return(F)}

with increasing inaccuracy when L grows, obviously.

fun sums

Posted in Books, Kids, Statistics with tags , , , , , , on May 26, 2021 by xi'an

Some sums and limits found from a [vacation] riddle by The Riddler:

For the first method, Friend 1 takes half of the cake, Friend 2 takes a third of what remains, and so on. After  infinitely many friends take their respective pieces, you get whatever is left.

\lim_{k\to\infty}\prod_{i=2}^k\left(1-\dfrac{1}{i}\right) = \lim_{k\to\infty} \dfrac{1}{k} = 0

For the second method, Friend 1 takes ½² of the cake, Friend 2 takes ⅓² of what remains, and so on. After infinitely many friends take their respective pieces, you get whatever is left.

\lim_{k\to\infty}\prod_{i=2}^k\left(1-\dfrac{1}{i^2}\right) = \lim_{k\to\infty}\dfrac{k+1}{2k} = \dfrac{1}{2}

For the third method, Friend 1 takes ½² of the cake, Friend 2 takes ¼² of what remains, Friend 3 takes ⅙² of what remains after Friend 2, and so on. After your infinitely many friends take their respective pieces, you get whatever is left.

\lim_{k\to\infty}\prod_{i=2}^k\left(1-\dfrac{1}{4i^2}\right) = \lim_{k\to\infty}\dfrac{4(2k+1)}{3\pi k} = \dfrac{2}{\pi}