Archive for the Books Category

simulating hazard

Posted in Books, Kids, pictures, Statistics, Travel with tags , , , , , , , , , , , , on May 26, 2020 by xi'an

A rather straightforward X validated question that however leads to an interesting simulation question: when given the hazard function h(·), rather than the probability density f(·), how does one simulate this distribution? Mathematically h(·) identifies the probability distribution as much as f(·),

1-F(x)=\exp\left\{ \int_{-\infty}^x h(t)\,\text{d}t \right\}=\exp\{H(x)\}

which means cdf inversion could be implemented in principle. But in practice, assuming the integral is intractable, what would an exact solution look like? Including MCMC versions exploiting one fixed point representation or the other.. Since

f(x)=h(x)\,\exp\left\{ \int_{-\infty}^x h(t)\,\text{d}t \right\}

using an unbiased estimator of the exponential term in a pseudo-marginal algorithm would work. And getting an unbiased estimator of the exponential term can be done by Glynn & Rhee debiasing. But this is rather costly… Having Devroye’s book under my nose [at my home desk] should however have driven me earlier to the obvious solution to… simply open it!!! A whole section (VI.2) is indeed dedicated to simulations when the distribution is given by the hazard rate. (Which made me realise this problem is related with PDMPs in that thinning and composition tricks are common to both.) Besides the inversion method, ie X=H⁻¹(U), Devroye suggests thinning a Poisson process when h(·) is bounded by a manageable g(·). Or a generic dynamic thinning approach that converges when h(·) is non-increasing.

bloggin’ nebulas [link]

Posted in Books, pictures with tags , , , , on May 25, 2020 by xi'an

Just to point out that the SF and fantasy editor Tor Books has posted on its site a series of blog posts on all the competitors for the 2019 Nebula Novel Award, including one of Gideon the Ninth I have enjoyed very much. With the mention there that the novel could be seen as “the Mobius Strip of over-the-topness”! To be announced on May the 30th.

babbage in, babbage out?!

Posted in Books, Kids, Statistics with tags , , , , , , on May 25, 2020 by xi'an

When checking for the origin of “garbage in, garbage out” on Wikipedia, I came upon this citation from Charles Babbage:

“On two occasions I have been asked, “Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?” … I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.”

following earlier quotes from him on this ‘Og.

a journal of the plague year [confined reviews]

Posted in Books, pictures, Travel, Wines with tags , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , on May 23, 2020 by xi'an

Watched TV series His Dark Materials produced for the BBC, which is much much better than the earlier film, as the actors are all fabulous—first and foremost Lyra, but also Ma Costa, the Gyptian Muter Courage—, the gypsy community is given a much stronger role, the characters are deep and complex, as eg Mrs and Mr Coulter, both ready to sacrifice kids for the greater “good” without appearing as absolute monsters! The special effects are a wee bit deficient as often with BBC productions but not enough to make a case. Although I sort of cringed each time a bear moved!

Read The Voyage of the Jerle Shannara trilogy by Terry Brooks, which I noticed standing on my son’s bookshelves. The original Shannara Trilogy was one of the very first fantasy books I read in English in my undergrad years (after Lord of the Rings of course and possibly The Chronicles of Thomas Covenant), which did not leave me with an everlasting feeling of superlative literature, to say the least. This avatar of the original Sword of Shannara trilogy did nothing to improve my feelings as the plot is lazy at best, with super-powered villains suddenly acting, last second deus ex machina rescues, endless internal debates, heavy hints at treacheries and double-treacheries, and, worst of all!, intrusion of 20th century technology, e.g., computers, AIs and robots, that the far future characters make sense of. Only suitable for a time of lockdown and even then… I should have left it on the bookshelf! Incidentally, one fight scene against a cyborg was highly reminiscent of the black knight scene in Holy Grail!

Watched by chance Tarantino’s Reservoir Dogs. For the first time. And was totally un-impressed. Highly pretentious construction falling flat from being a modern reconstruction of antique dramas, endless dialogues (which could have been cut by half if removing all the occurrences of fucking from them), boring and threadbare story, and artificial characters that essentially make no sense. I cannot fathom why this film is so highly ranked..! (And even less to witness it being compared with Rashomon!)

Read [part] of Jin Yong’s Legends of the Condor Heroes (射鵰英雄傳) but, lockdown or not, I simply could not finish it. Despite its fantasy approach to Chinese martial arts, which I usually enjoy (at least in planes!), and some proximity with the Judge Dee stories by van Gulik, the story felt very contrived and somewhat out of reach, plus [not yet] Genghis Khan being depicted in a fairly positive way [at least in the part I read]. Too irrealist for my reading buds, I presume…

Cooked plenty of new dishes, thanks to the delivery of weekly farmer boxes, from radish stems & buckwheat pancakes to celery roots purées, to fregola sarda (leftovers from ISBA 2016!) con acciughe, to chard gratins, to pea pod and cauliflower core soups, to flaxseed bread and buckwheat naans (as we ran out of wheat flour). We also managed to use and survive most of the out-of-date cans and bags that had stood forgotten in the back of our cupboard… Not visiting a supermarket for two months was actually most pleasant, living very nicely from the above mentioned farmer boxes and the occasional delivery from a cheesemonger, and supplementing weekly visits to the baker with attempts at home made bread.

Read Matha Well’s Murderbot diaries, my first read on a Kindle!, for free courtesy of Tor. Starting with All Systems Red, which won the 2017 Nebula Award for Best Novella, the 2018 Hugo Award for Best Novella, the 2018 Locus Award, and the American Library Association‘s Alex Award. Very good if somewhat classical (Blade Runner anyone?!) trope of the rogue robot turned autonomous and human, so human! This is a sequence of novellas which means a fast-paced story and an efficient style. (Including a less exciting third novella, due to a lazy scenario.) More mind-candy à la John Scalzi than profound literature but quite enjoyable for a quick read during lunch or tea break! But which induced me to buy the first and incoming novel in the series,  Network Effect. (To be commented in a subsequent entry…)

Leading to (re)read the Interdependency trilogy by John Scalzi, the last volume in the series being just out. Very lazy buildup, in the traditional spirit of a few people driving the future of the entire Universe, with unlimited resources and unrestricted hacking abilities, but with funny dialogues, as usual with Scalzi. In this binge (re)read, I actually realised the frustrating intricacies of Kindle ordering as (i) I could not use my amazon.com account and hence none of my associate gains (ii) I could not merge several amazon.fr accounts and (iii) prices varied a lot between using directly the Kindle and ordering from amazon.fr…

And even growing some salads and radishes over the two months and eating them before the end of the lockdown, as the weather in Paris was quite mild most of the time. Although it meant a daily-basis fight with slugs. The arugula did not resist that well, though…

Reading Tade Thompson’s Rosewater for more than a month, having trouble keeping my concentration as the story goes in loops and not a particularly well settled plot. With a central idea of an alien race taking over humanity a few cells at a time. Which reminded me of Greg Bear’s Blood Music I read during the first year of my PhD. The book has some appeal, from being located in Nigeria 30 years from now to America having completely vanished from the map after Trump pulled the ultimate drawbridge. It won the 2019 Arthur Clarke Award after all! But I found it too hard to complete to even consider embarking upon the next two volumes on the trilogy…

a new Monty Hall riddle

Posted in Books, Kids, Mountains, pictures, R, Statistics, Travel with tags , , , , , , , , , on May 22, 2020 by xi'an

The Riddler was sort of feeling the rising boredom of being under lockdown when proposing the following variant to the Monty Hall puzzle:

There are zero to three goats, with a probability ¼ each, and they are allocated to different doors uniformly among the three doors of the show. After the player chooses a door, Monty opens another door hidding a goat or signals this is impossible. Given that he did open a door, what is the probability that the player’s door does not hide a goat?

Indeed, a straightforward conditional probability computation considering all eight possible cases with the four cases corresponding to Monty opening a door leads to a probability of 3/8 for the player’s door. As confirmed by the following R code:

s=sample
m=c(0,0)
for(t in 1:1e6)m=m+(range(s(1:3,s(1:3,1)))>1)

not a Bernoulli factory

Posted in Books, Kids, pictures, R with tags , , , , , , , on May 20, 2020 by xi'an

A Riddler riddle I possibly misunderstood:

Four isolated persons are given four fair coins, which can be either flipped once or returned without being flipped. If all flipped coins come up heads, the team wins! Else, if any comes up tails, or if no flip at all is done, it looses. Each person is further given an independent U(0,1) realisation. What is the best strategy?

Since the players are separated, I would presume the same procedure is used by all. Meaning that a coin is tossed with probability p, ie if the uniform is less than p, and untouched otherwise. The probability of winning is then

4(1-p)³p½+6(1-p)³p½²+4(1-p)p³½³+p⁴½⁴

which is maximum for p=0.3420391, with a winning probability of 0.2848424.

And an extra puzzle for free:

solve xxxx=2020

Where the integral part is the integer immediately below x. Puzzle that I first fail solving by brute force, because I did not look at negative x’s… Since the fourth root of 2020 is between 6 and 7, the solution is either x=6+ε or x=-7+ε, with ε in (0,1). The puzzle then becomes either

(6+ε)⌊(6+ε)⌊(6+ε)⌊6+ε⌋⌋ = (6+ε)⌊(6+ε)⌊36+6ε⌋⌋ = (6+ε)⌊(6+ε)(36+⌊6ε⌋)⌋ = 2020

where there are 6 possible integer values for ⌊6ε⌋, with only ⌊6ε⌋=5 being possible, turning the equation into

(6+ε)⌊41(6+ε) = (6+ε)(246+⌊41ε) = 2020

where again only ⌊42ε=40 being possible, ending up with

1716+286ε = 2020

which has no solution in (0,1). In the second case

(-7+ε)(-7+ε)(-7+ε)-7+ε⌋⌋ = (-7+ε)(-7+ε)(49+-7ε⌋)= 2020

shows that only -7ε=-3 is possible, leading to

(-7+ε)⌊46(-7+ε)) = (-7+ε) (-322+46ε⌋)=2020

with only 46ε=17 possible, hence

2135-305ε=2020

and

ε=115/305.

A brute force simulated annealing resolution returns x=-6.622706 after 10⁸ iterations. A more interesting question is to figure out the discontinuity points of the function

ℵ(x) = xxxx

as they seem to be numerous:

For instance, only 854 of the first 2020 integers enjoy a solution to ℵ(x)=n.

Le Monde puzzle [#1144]

Posted in Books, Kids with tags , , , , , , on May 19, 2020 by xi'an

The weekly puzzle from Le Monde is again using 2020 but not R!

Two teams involve a prime total number m of participants, with each player getting between 0 and 100 points. The total score for both teams is 2020, with team B less than team A on average. A single transfer from A to B increases the average scores for both A and B by 1/2. What is the difference of the averages? The transfer(ed) player, Camélia, had 5 points less  than the average score for A. What was the score of Camélia?

but I could not find a brute force solution and ended up finding that 2×2020=2x2x5x101 is a multiple of m, which leaves only

m=101

as the possible number of players. Which almost immediately leads to a difference of m/2 between the average scores. And then almost as immediately to Camélia’s score being 60. If one really needed an R function

k=function(a){((C<-71-a)>0)&(C+(a-1)/2<102)
              &(C-((102-a)/2)>0)&(C+5==(C+(a-1)/2))}

does return a=11 but this is 100% useless!