## riddle on a circle

Posted in Books, Kids, R, Travel with tags , , , , , , , on December 22, 2019 by xi'an

The Riddler’s riddle this week provides another opportunity to resort to brute-force simulated annealing!

Given a Markov chain defined on the torus {1,2,…,100} with only moves a drift to the right (modulo 100) and a uniformely random jump, find the optimal transition matrix to reach 42 in a minimum (average) number of moves.

Which I coded in my plane to Seattle, under the assumption that there is nothing to do when the chain is already in 42. And the reasoning that there is not gain (on average) in keeping the choice between right shift and random jump random.

```dure=min(c(41:0,99:42),50)
temp=.01
for (t in 1:1e6){
i=sample((1:100)[-42],1)
dura=1+mean(dure)
if (temp*log(runif(1))<dure[i]-dura) dure[i]=dura
if(temp*log(runif(1))<dure[i]-(dura<-1+dure[i*(i<100)+1]))
dure[i]=dura
temp=temp/(1+.1e-4*(runif(1)>.99))}
```

In all instances, the solution is to move at random for any position but those between 29 and 41, for an average 13.64286 number of steps to reach 42. (For values outside the range 29-42.)

## hiking the Dungeness spit

Posted in Mountains, pictures, Travel with tags , , , , , , , , , , , on August 16, 2015 by xi'an

We had a great hike while staying on the Olympic peninsula, walking a sand spit housing the Dungeness National Wildlife Refuge, located at the end of the Puget Sound and the Strait of Juan de Fuca. The sand spit goes into sea for five and a half miles, ending up at a decommissioned lighthouse that has been preserved by a local association, with voluntary keepers staying there one week at a time. Which is a great way to spend a retreat far from the maddening crowd… Except for the few hikers managing the walk to the lighthouse, of course!

The walk is quite easy, on packed sand, provided there is no high tide at the time, and few enough people embark on the eleven miles trip to make it quiet and peaceful. It is a wee bit monotonous, obviously, even though watching for birds and flotsam and jetsam enlivens the trip. Nothing extreme, obviously, but great views on the Olympic National Park peaks. With a cooling wind that hid the strength of the sun. As we discovered too late!

While there are many potential species of birds taking refuge on that preserved spit, we did not see many. Besides the obvious gulls and relatives, a heron, two types of sandpipers, and a loon-like bird at sea. Plus a few seals fishing at sea, clearly not bothered by the potential orcas around the spit. That we sadly did not see.