## Posts by xi'an

# Author: xi'an

#### Gibbs sampling with incompatible conditionals

Feed: R-bloggers. Author: xi'an. An interesting question (with no clear motivation) on X validated wondering why a Gibbs sampler produces NAs… Interesting because multi-layered: The attached R code indeed produces NAs because it calls the Negative Binomial Neg(x¹,p) random generator with a zero success parameter, x¹=0, which automatically returns NAs. This can be escaped by returning a one (1) instead. The Gibbs sampler is based on a Bin(x²,p) conditional for X¹ and a Neg(x¹,p) conditional for X². When using the most standard version of the Negative Binomial random variate as the number of failures, hence supported on 0,1,2…. these two ... Read More

#### a non-riddle

Feed: R-bloggers. Author: xi'an. Unless I missed a point in the last riddle from the Riddler, there is very little to say about it: Given N ocre balls, N aquamarine balls, and two urns, what is the optimal way to allocate the balls to the urns towards drawing an ocre ball with no urn being empty? Both my reasoning and a two line exploration code led to having one urn with only one ocre ball (and no acquamarine ball) and all the other balls in the second urn. odz Related To leave a comment for the author, please follow the ... Read More

#### CRAN does not validate R packages!

Feed: R-bloggers. Author: xi'an. A friend called me the other day for advice on how to submit an R package to CRAN along with a proof his method was mathematically sound. I replied with some items of advice taken from my (limited) experience with submitting packages. And with the remark that CRAN would not validate the mathematical contents of the associated package manual. Nor even the validity of the R code towards delivering the right outcome as stated in the manual. This shocked him quite seriously as he thought having a package accepted by CRAN was a stamp of validation ... Read More

#### Le Monde puzzle [#1105]

Feed: R-bloggers. Author: xi'an. Another token game as Le Monde mathematical puzzle: Archibald and Beatrix play with a pile of n>100 tokens, sequentially picking m tokens from the pile with m being a prime number [including m=1] or a multiple of 6, the winner taking the last tokens. If Beatrix knows n and proposes to Archibald to start, what is the value of n? Which cannot be solved in a few lines of R code: k since it returned no unsuccessful value above 100! With 4, 8, 85, 95, and 99 as predecessors. A rather surprising outcome and a big ... Read More

#### Le Monde puzzle [#1104]

Feed: R-bloggers. Author: xi'an. A palindromic Le Monde mathematical puzzle: In a monetary system where all palindromic amounts between 1 and 10⁸ have a coin, find the numbers less than 10³ that cannot be paid with less than three coins. Find if 20,191,104 can be paid with two coins. Similarly, find if 11,042,019 can be paid with two or three coins. Which can be solved in a few lines of R code: coin=sort(c(1:9,(1:9)*11,outer(1:9*101,(0:9)*10,"+"))) amounz=sort(unique(c(coin,as.vector(outer(coin,coin,"+"))))) amounz=amounz[amounz and produces 10 amounts that cannot be paid with one or two coins. It is also easy to check that three coins are enough to ... Read More

#### riddles on Egyptian fractions and Bernoulli factories

Feed: R-bloggers. Author: xi'an. Two fairy different riddles on the weekend Riddler. The first one is (in fine) about Egyptian fractions: I understand the first one as Find the Egyptian fraction decomposition of 2 into 11 distinct unit fractions that maximises the smallest fraction. And which I cannot solve despite perusing this amazing webpage on Egyptian fractions and making some attempts at brute force random exploration. Using Fibonacci’s greedy algorithm. I managed to find such decompositions 2 = 1 +1/2 +1/6 +1/12 +1/16 +1/20 +1/24 +1/30 +1/42 +1/48 +1/56 after seeing in this short note 2 = 1 +1/3 +1/5 ... Read More

#### A precursor of ABC-Gibbs

Feed: R-bloggers. Author: xi'an. Following our arXival of ABC-Gibbs, Dennis Prangle pointed out to us a 2016 paper by Athanasios Kousathanas, Christoph Leuenberger, Jonas Helfer, Mathieu Quinodoz, Matthieu Foll, and Daniel Wegmann, Likelihood-Free Inference in High-Dimensional Model, published in Genetics, Vol. 203, 893–904 in June 2016. This paper contains a version of ABC Gibbs where parameters are sequentially simulated from conditionals that depend on the data only through small dimension conditionally sufficient statistics. I had actually blogged about this paper in 2015 but since then completely forgotten about it. (The comments I had made at the time still hold, already ... Read More

#### an attempt at code golf

Feed: R-bloggers. Author: xi'an. Having discovered codegolf on Stack Exchange a few weeks ago, I spotted a few interesting puzzles since then but only got the opportunity at a try over a quiet and rainy weekend (and Robin being on vacation)! The challenge was to write an R code for deciding whether or not a given integer n is congruent or not, when congruent means that it is the surface of a rectangle triangle with all three sides rational. The question included a pointer to the Birch and Swinnerton-Dyer conjecture as a mean to check congruence although the real solution ... Read More

#### easy Riddler

Feed: R-bloggers. Author: xi'an. The riddle of the week is rather standard probability calculus If N points are generated at random places on the perimeter of a circle, what is the probability that you can pick a diameter such that all of those points are on only one side of the newly halved circle? Since it is equivalent to finding the range of N Uniform variates less than ½. And since the range of N Uniform variates is distributed as a Be(N-1,2) random variate. The resulting probability, which happens to be exactly , is decreasing exponentially, as shown below… Related ... Read More

#### a perfectly normally distributed sample

Feed: R-bloggers. Author: xi'an. When I saw this title on R-bloggers, I was wondering how “more perfect” a Normal sample could be when compared with the outcome of rnorm(n). Hence went checking the original blog on bayestestR in search of more information. Which was stating nothing more than how to generate a sample is perfectly normal by using the rnorm_perfect function. Still unsure of the meaning, I contacted one of the contributors who replied very quickly …that’s actually a good question. I would say an empirical sample having characteristics as close as possible to a cannonic gaussian distribution. and again ... Read More

## Recent Comments