Articles by xi'an

spiral matrix [X-validated]

February 10, 2022 | xi'an

One recent code-golf challenge was to write the shortest possible code representing the first n² integers in a spiral progression, e.g., 0 1 2 3 4 15 16 17 18 5 14 23 24 19 6 13 22 21 20 7 12 11 10 9 8 While I did not come close to the best […] [Read more...]

blind monty hall

January 9, 2022 | xi'an

As I was waiting for my boat on a French Guiana beach last week, I thought back about a recent riddle from The Riddler where an item does a random walk over a sequence of N integers. Behind doors. The player opens a door at the same rate as the ...
[Read more...]

triple ruin

December 27, 2021 | xi'an

An almost straightforward riddle from The Riddler involving a triple gambler’s ruin: Dawn competes against three players Alessandra, Berenike, and Chinue, with probabilities of winning one round ¾, ½, and ¼, respectively, until the cumulated score reaches ±15, ±30, and ±45, for the first, second, and third games. What is Dawn’s optimal sequence of ... [Read more...]

dice and sticks

November 18, 2021 | 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(...
[Read more...]

Xing glass bridges [or not]

November 9, 2021 | xi'an

A riddle from the Riddler surfing on Squid Games. Evaluating the number of survivors (out of 16 players) able to X the glass bridge, when said bridge is made of 18 consecutive steps, each involving a choice between a tempered and a non-tempered glass square. Stepping on a non-tempered square means death, ...
[Read more...]

[maximin] geometric climbing

October 4, 2021 | xi'an

A puzzle from The Riddler this week returning to the ranking of climbing competitors in Tokyo. And asking for the maximin score, that is, the worst possible absolute score guaranteeing victory. In the case of eight competitors, a random search for a maximin over 10⁶ draws leads to a value of 48=1...
[Read more...]

1 / duh?!

September 27, 2021 | xi'an

An interesting case on X validated of someone puzzled by the simulation (and variance) of the random variable 1/X when being able to simulate X. And being surprised at the variance of the ratio being way larger than the variances of both numerator and ...
[Read more...]

likelihood inference with no MLE

July 28, 2021 | xi'an

“In a regular full discrete exponential family, the MLE for the canonical parameter does not exist when the observed value of the canonical statistic lies on the boundary of its convex support.” Daniel Eck and Charlie Geyer just published an interesting and intriguing paper on running efficient inference for discrete ...
[Read more...]

multinomial but unique

July 15, 2021 | 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, ...
[Read more...]

almost reversed 2-lag Markov chain

July 6, 2021 | 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 ... [Read more...]

breaking sticks of various length

July 5, 2021 | 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 ...
[Read more...]

inf R ! [book review]

June 9, 2021 | xi'an

Thanks to my answering a (basic) question on X validated involving an R code, R mistakes and some misunderstanding about Bayesian hierarchical modelling, I got pointed out to Patrick Burns’ The R inferno. This is not a recent book as the second edition is of 2012, with a 2011 version still available ...
[Read more...]

on approximations of Φ and Φ⁻¹

June 2, 2021 | xi'an

As I was working on a research project with graduate students, I became interested in fast and not necessarily very accurate approximations to the normal cdf Φ and its inverse. Reading through this 2010 paper of Richards et al., using for instance (with another version replacing 2/π with the squared root of π/8) and $...
[Read more...]

scale matters [maths as well]

June 1, 2021 | xi'an

A question from X validated on why an independent Metropolis sampler of a three component Normal mixture based on a single Normal proposal was failing to recover the said mixture… When looking at the OP’s R code, I did not notice anything amiss at first glance (I was about ...
[Read more...]

more air for MCMC

May 29, 2021 | xi'an

Aki Vehtari, Andrew Gelman, Dan Simpson, Bob Carpenter, and Paul-Christian Bürkner have just published a Bayesian Analysis paper about using an improved R factor for MCMC convergence assessment. From the early days of MCMC, convergence assessment has been a recurring (and recurrent!) question in the community. First leading to ...
[Read more...]

bean bag win

May 18, 2021 | xi'an

A quick riddle from The Riddler, where a multiple step game sees a probability of a 3 point increase of .4 and a probability of a 1 point increase of .3 with a first strategy (A), versus a probability of a 3 point increase of .4 and a probability of a 1 point increase of […]
[Read more...]

R rexp()

May 17, 2021 | xi'an

Following a question on X validated about the reasons for coding rexp() following Ahrens & Dieter (1972) version, I re-read Luc Devroye’s explanations. Which boils down to an optimised implementation of von Neumann’s Exponential generator. The central result is that, for any μ__0, M a Geometric variate with failure probability exp(... [Read more...]

unbalanced sampling

May 16, 2021 | xi'an

A question from X validated on sampling from an unknown density f when given both a sample from the density f restricted to a (known) interval A , f¹ say, and a sample from f restricted to the complement of A, f² say. Or at least on producing an estimate of ...
[Read more...]

warped Cauchys

May 3, 2021 | xi'an

A somewhat surprising request on X validated about the inverse cdf representation of a warped Cauchy distribution. I had not come across this distribution, but its density being means that it is the superposition of shifted Cauchys on the unit circle (with nice complex representations). As such, it is easily ...
[Read more...]

one-way random walks

May 1, 2021 | xi'an

A rather puzzling riddle from The Riddler on an 3×3 directed grid and the probability to get from the North-West to the South-East nodes following the arrows. Puzzling because while the solution could be reasonably computed with an R code like suc...
[Read more...]
1 2 3 45

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)