## my demonic talk

Posted in Statistics with tags , , , , , , , , , , , on May 13, 2020 by xi'an

## riddles on a line [#2]

Posted in Books, Kids, R with tags , , , , , , , on September 11, 2018 by xi'an

A second Riddle(r), with a puzzle related with the integer set Ð={,12,3,…,N}, in that it summarises as

Given a random walk on Ð, starting at the middle N/2, with both end states being absorbing states, and a uniform random move left or right of the current value to the (integer) middle of the corresponding (left or right) integer interval, what is the average time to one absorbing state as a function of N?

Once the Markov transition matrix M associated with this random walk is defined, the probability of reaching an absorbing state in t steps can be derived from the successive powers of M by looking at the difference between the probabilities to be (already) absorbed at both t-1 and t steps. From which the average can be derived.

```avexit <- function(N=100){
#transition matrix M for the walk
#1 and N+2 are trapping states
tranz=matrix(0,N+2,N+2)
tranz[1,1]=tranz[N+2,N+2]=1
for (i in 2:(N+1))
tranz[i,i+max(trunc((N+1-i)/2),1)]=tranz[i,i-max(trunc((i-2)/2),1)]=1/2
#probabilities of absorption
prowin=proloz=as.vector(0)
init=rep(0,N+2)
init[trunc((N+1)/2)]=1 #first position
curt=init
while(1-prowin[length(prowin)]-proloz[length(prowin)]>1e-10){
curt=curt%*%tranz
prowin=c(prowin,curt[1])
proloz=c(proloz,curt[N+2])}
#probability of new arrival in trapping state
probz=diff(prowin+proloz)
return(sum((2:length(proloz))*probz))}
```

leading to an almost linear connection between N and expected trapping time.

## sharp ends [book review]

Posted in Books, Kids, Travel with tags , , , , , , , on September 2, 2018 by xi'an

A chance encounter with an itinerant bookstore at the market of Tofino, Van Isle, BC, led me to buy this collection of short stories by Joe Abercrombie, called Sharp Ends. All set in the same universe as the great series of novels he wrote in the past ten years, involving second, third and fourth rate characters, with a few major ones popping in on the side. Including my favourite, Ninefinger. These short stories have appeared here and there across the years, but reading them together (for the first time) within a few days (of vacation) was utterly pleasant, with some threads running through most and some enjoyable recurrent characters. I remembered enough of the original First Law books to settle back in their universe, ten years later! And short stories are quite suited to Abercrombie’s style of stories, the dark and grim ending occurring always too quickly for the main character! Now this set me wondering as to why there was no recent book by this author, except for the disappointing young adult Half something trilogy. Which  read I did not complete. Reading his blog for the first time in many years, I learned that a new trilogy is in the making, set in the same universe (and avoiding mixing dark fantasy with western!). Looking forward this new series!!!

## going on a bear [and a whale] hunt

Posted in Mountains, pictures, Travel with tags , , , , , , , , , , , , , , on August 27, 2018 by xi'an

Among many and diverse outdoor activities during our vacations on Vancouver Island, a rather unique trip was to go kayaking near Tofino to try to watch black bears. In a group of three sea kayaks, at dusk, with a fantastic guide. Bears foraging for crabs on the shore at low tide are not unusual but, as it happened, we were quite lucky to spot five different bears over the two hours we paddle along the fjord, including a big one standing on its back legs to catch berries. From a few meters away, this was an incredible sight! [About the title: We’re going on a bear hunt is a classic of children books.]
We were less lucky when whaling out at sea, only spotting a blow on the trip, even though we spotted many seals and a few sea otters. The most exhilarating wildlife experience of the Van trip was however swimming with seals on the northern coast of the island, where on several days one or two seals came to check on me while I was swimming in the ocean in the early morning. (Managing to avoid cold shock and hypothermia by only staying less than 20 minutes in the 17⁰ water.)

## the ocean at the end of the lane [book review]

Posted in Books, Kids, pictures, Travel with tags , , , , , , , , , , , , , on August 24, 2018 by xi'an

While in Vancouver, waiting for a friend at the Waterfront ferry station, we entered the Simon Fraser University bookshop across the street. This was a most disconcerting experience in that the bookstore contained essentially no book! Just a tiny bookshelf with local authors and another one with a medley of genres. Including Gaiman’s The Ocean at the End of the Lane. Which I bought against my better judgement as I had tried to read American Dogs years ago and failed. (But liked very much Neverwhere, again a chance occurrence on a bookstore shelf!) As I started reading the book on the ferry to Vancouver Island, hence on the Pacific Ocean!, I first thought this was about the author’s childhood in rural Sussex, with no other friends than his books, finding some ways to relate to the story of a modest household in the early 60’s, only to be interrupted by three whales swimming along the ferry route. The cheek of them! When I picked up the short novel later in Tofino (with Tonkin Beach above), reality started to unravel (in the book!) and horror to creep in (!). Without getting into spoilers, the  other world or old country starts appearing to the narrator, a seven year old, with about everything taking another and sinister meaning. And no-one else in his household paying any attention to his warnings. What I really enjoy in the book is the sheer ambiguity of the tale, where one cannot be sure this is pure fantasy made up by a lonely seven year old who strongly dislikes a new nanny and is impacted by his parents’ relationship, or an opening into that alternate reality and its dangers that he and only he is able to enter. The book never concludes and this is a strength of the story. Which works for both adult and children readers. It also reminded me of Miyazaki’s Chihiro Spirited Away (千と千尋の神隠し), in that the supernatural beings here and there are neither evil nor good but simply utterly alien. (This fantastic² movie is considered by my daughter as the most traumatic one she ever saw as a child!) Concluding about the book, this was a very good read, somewhat on the light side although full of forking paths.