11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

246 8. MARKOV CHAIN MONTE CARLO ESTIMATIONafter 10000 weeksisland2 4 6 8 10number of weeks0 500 1000 15000 50 100 150 200week2 4 6 8 10islandFIGURE 8.2. Results of the king following the Metropolis algorithm. elehand plot shows the king’s position (vertical axis) across weeks (horizontalaxis). In any particular week, it’s nearly impossible to say where theking will be. e righthand plot shows the long-run behavior of the algorithm,as the time spent on each island turns out to be proportional to itspopulation size.biggest island, number 10). en the for loop steps through the weeks. Each week, it recordsthe king’s current position. en it simulates a coin flip to nominate a proposal island. eonly trick here lies in making sure that a proposal of “11” loops around to island 1 and aproposal of “0” loops around to island 10. Finally, a random number between zero and oneis generated (runif(1)), and the king moves, if this random number is less than the ratio ofthe proposal island’s population to the current island’s population (proposal/current).You can see the results of this simulation in FIGURE 8.2. e lehand plot shows theking’s location across the first 200 weeks of his simulated travels. As you move from the leto the right in this plot, the points show the king’s location through time. e king travelsamong islands, or sometimes stays in place for a few weeks. is plot demonstrates the seeminglypointless path the Metropolis algorithm sends the king on. e righthand plot showsthat the path is far from pointless, however. e horizontal axis is now islands (and theirrelative populations), while the vertical is the number of weeks the king is found on each.Aer the entire 10-thousand weeks of the simulation, you can see that the proportion of timespent on each island converges to be almost exactly proportional to the relative populationsof the islands.e algorithm will still work in this way, even if we allow the king to be equally likelyto propose a move to any island from any island, not just among neighbors. As long asKing Markov still uses the ratio of the proposal island’s population to the current island’spopulation as his probability of moving, in the long run, he will spend the right amount oftime on each island. e algorithm would also work for any size archipelago, even if the kingdidn’t know how many islands were in it. All he needs to know at any point in time is thepopulation of the current island and the population of the proposal island. en, without any

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!