## Archive for Tofino

## beach walk in the fog [jatp]

Posted in pictures, Running, Travel with tags British Columbia, Canada, fog, hiking, jatp, Long Beach, Pacific North West, Pacific Ocean, Pacific Rim, Tofino, vacations, Vancouver Island on August 22, 2018 by xi'an## riddles on a line

Posted in Books, Kids, R with tags British Columbia, dynamic programming, FiveThirtyEight, mathematical puzzle, Pascal triangle, probability, R, The Riddler, Tofino, Vancouver Island on August 22, 2018 by xi'an**I**n the Riddler of August 18, two riddles connected with the integer set Ð={2,3,…,10}:

*Given a permutation of Ð, what is the probability that the most likely variation (up or down) occurs at each term?**Given three players choosing three different integers in Ð sequentially, and rewards in Ð allocated to the closest of the three players (with splits in case of equal distance), what is the reward for each given an optimal strategy?*

For the first question, a simple code returns 0.17…

winofail<-function(permz){ if (length(permz)>1){ lenoperm=length(permz[-1])/2 win=(permz[1]<permz[2])*(sum(permz[-1]>permz[1])>lenoperm)+ (permz[1]>permz[2])*(sum(permz[-1]<permz[1])>lenoperm)+ (runif(1)<.5)*(sum(permz[-1]>permz[1])==lenoperm) win=win&&winofail(permz[-1]) }else win=TRUE return(win)}

(but the analytic solution exhibits a cool Pascal triangular relation!) and for the second question, a quick recursion or dynamic programming produces 20, 19, 15 as the rewards (and 5, 9, 8 as the locations)

gainz<-function(seqz){ difz=t(abs(outer(2:10,seqz,"-"))) cloz=apply(difz,2,rank) return(apply(rbind(2:10,2:10,2:10)* ((cloz==1)+.5*(cloz==1.5)),1,sum))} timeline<-function(prev){ if (length(prev)==0){ sol=timeline(10);bez=gainz(sol)[1] for (i in 2:9){ bol=timeline(i);comp=gainz(bol)[1] if (comp>bez){ bez=comp;sol=bol}}} if (length(prev)==1){ bez=-10 for (i in (2:10)[-(prev-1)]){ bol=timeline(c(prev,i)) comp=gainz(bol)[2] if (comp>bez){ bez=comp;sol=bol}}} if (length(prev)==2){ bez=-10 for (i in (2:10)[-(prev-1)]){ bol=c(prev,i) comp=gainz(bol)[3] if (comp>bez){ bez=comp;sol=bol}}} return(sol)}

After reading the solution on the Riddler, I realised I had misunderstood the line as starting at 2 when it was actually starting from 1. Correcting for this leads to the same 5, 9, 8 locations of picks, with rewards of 21, 19, 15.

## Tofino from the air [jatp]

Posted in Statistics with tags British Columbia, Canada, hiking, jatp, Lone Cone Mountain, Meares Island, Pacific Ocean, Pacific Rim, Tofino, Van Isle, Vancouver Island on August 21, 2018 by xi'an## a funny mistake

Posted in Statistics with tags British Columbia, Canada, Euler's function, FiveThirtyEight, Leonhard Euler, Lone Cone Mountain, mathematical puzzle, Meares Island, stopping rule, The Riddler, Tofino, Vancouver Island on August 20, 2018 by xi'an**W**hile watching the early morning activity in Tofino inlet from my rental desk, I was looking at a recent fivethirthyeight Riddle, which consisted in finding the probability of stopping a coin game which rule was to wait for the n consecutive heads if (n-1) consecutive heads had failed to happen when requested, which is

p+(1-p)p²+(1-p)(1-p²)p³+…

or

While the above can write as

or

hence suggesting

the answer is (obviously) false and the mistake in separating the series into a difference of series is that both terms are infinite. The correct answer is actually

which is Euler’s function. Maybe nonstandard analysis can apply to go directly from the difference of the infinite series to the answer!

## asymptotics of M³C²L

Posted in Statistics with tags asymptotics, fog, maximum likelihood estimation, M³C²L, Monte Carlo Statistical Methods, Pacific North West, Tofino, Vancouver Island on August 19, 2018 by xi'an**I**n a recent arXival, Blazej Miasojedow, Wojciech Niemiro and Wojciech Rejchel establish the convergence of a maximum likelihood estimator based on an MCMC approximation of the likelihood function. As in intractable normalising constants. The main result in the paper is a Central Limit theorem for the M³C²L estimator that incorporates an additional asymptotic variance term for the Monte Carlo error. Where both the sample size n and the number m of simulations go to infinity. Independently so. However, I do not fully perceive the relevance of using an MCMC chain to target an importance function [which is used in the approximation of the normalising constant or otherwise for the intractable likelihood], relative to picking an importance function h(.) that can be directly simulated.