## 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}$

Posted in Statistics with tags , , , , on April 9, 2021 by xi'an

First, an express riddle from the Riddler of last week:

An infant naps peacefully for two hours at a time and then wakes up, crying, due to hunger. After eating quickly, the infant plays alone for another hour, and then cries due to tiredness. This cycle repeats over the course of a 12-hour day. (The baby sleeps peacefully 12 hours through the night.) At a random time during the day, you spend 30 minutes with your baby and then the baby cries. What’s the probability that your baby is hungry?

The probabilistic setting is somewhat unclear, in particular because the last daytime nap is followed immediately with a 12 hour night sleep. Or the 12 hour night sleep is immediately followed by a one or two hour nap. Assuming a random starting time over the 12 hour period, denoting X as the time to the next crisis and Y as the nature of the cries (H versus T), it is straightforward to show that P(Y=H|X=30′) is ½. While it would be 1 for any duration larger than one hour.

Followed by an extra one this week:

Starting at a random time, 30 minutes go by with no cries. What is the probability that the next time your baby cries she will be hungry?

Which means computing P(Y=H|X>30′). Equal to ¾ in this case.

## plusquamperfect squares

Posted in Books, Kids, R with tags , , , on April 2, 2021 by xi'an

For some perfect squares, when you remove the last digit, you get another perfect square. The first five perfect squares are 16, 49, 169, 256 and 361. What are the next three ones? Is there a more than perfect square other than 169 such that removing the last two digits returns a perfect square?

Writing an R code for plusquamperfect squares is straightforward and returns the following first 20 values

 [1]         16         49        169        256        361       1444
[7]       3249      18496      64009     237169     364816     519841
[13]    2079364    4678569   26666896   92294449  341991049  526060096
[19]  749609641 2998438564


Adding the second constraint does not return a solution other than 169.

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

As The Riddler proposed for several weeks in a row a CrossProduct™ puzzle where 3 x n one-digit integers have to be deduced from their rowwise and columnwise products, I attempted writing an R solver by applying a few basic rules repeatedly, which worked for the first two puzzles, if not for the earlier one I solved by paper & pen (mostly) a few weeks ago, and again worked for the final one. The rules I used were to spot unique entries, forced entries by saturation, and forced digits (from the prime factor decomposition) again by saturation. Any further rule to add to the solver? (The R code is currently rather ugly!) Please, some more!

## new order

Posted in Books, Kids, R, Statistics with tags , , , , on February 5, 2021 by xi'an

The latest riddle from The Riddler was both straightforward: given four iid Normal variates, X¹,X²,X³,X⁴, what is the probability that X¹+X²<X³+X⁴ given that X¹<X³ ? The answer is ¾ and it actually does not depend on the distribution of the variates. The bonus question is however much harder: what is this probability when there are 2N iid Normal variates?

I posted the question on math.stackexchange, then on X validated, but received no hint at a possible simplification of the probability. And then erased the questions. Given the shape of the domain where the bivariate Normal density is integrated, it sounds most likely there is no closed-form expression. (None was proposed by the Riddler.) The probability decreases roughly in N³ when computing this probability by simulation and fitting a regression.

> summary(lm(log(p)~log(r)))

Residuals:
Min        1Q    Median        3Q       Max
-0.013283 -0.010362 -0.000606  0.007835  0.039915

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.111235   0.008577  -12.97 4.11e-13 ***
log(r)      -0.311361   0.003212  -96.94  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.01226 on 27 degrees of freedom
Multiple R-squared:  0.9971,	Adjusted R-squared:  0.997
F-statistic:  9397 on 1 and 27 DF,  p-value: < 2.2e-16