stretch_move: Update an ensemble of 'walkers' using the 'stretch move'

Description Usage Arguments Details Value Notes See Also

View source: R/gwmcmc.R

Description

stretch_move updates an ensemble of 'walkers' using the 'stretch move'.

Usage

1
stretch_move(posterior, theta, a = 2, chatter = 0, ...)

Arguments

posterior

(function) name of the log(posterior) function to sample from

theta

(array) nwalkers (rows) * M+2 (columns) the current position of each walker

a

(float) set the scale size of the random jumps

chatter

(integer) how verbose is the output? (0=quiet, 1=normal, 2=verbose)

...

(anything else) other arguments needed for posterior function

Details

A simple implementation of the 'strectch move' for the ensemble MCMC sampler proposed by Goodman & Weare (2010).

Value

An array containing the updated positions (in M-dimensional space) of each of the nwalkers walkers. The array is nwalkers (rows) * M+2 (columns). The last two columns list whether the proposed move was rejected or accepted (0 or 1, respectively) and the current (log) posteriod value.

Notes

At input the array theta gives the current position of each walker. There are nwalkers rows, one for each walker. Each row has M+2 columns. The first 1:M columns are the position of each walker, an M-dimensional vector. On output the position of each walker is updated. And the M+1 column is assigned 0 (rejected) or 1 (accepted) depending on whether each walker's position was updated this cycle (accept/reject the proposed update position). The M+2 column contains the log(posterior density) at each walker's current position (after update).

Each walker's position is updated in turn. The position of walker j is updated by randomly selecting another walker k from the ensemble (the complementary walker) and moving along the line joining the current position of walker j to walker k. The jump size is random and has the distribution suggested by Goodman & Weare (eqn 9). This updated position for walker i is then accepted or rejected with a probability that depends on the ratio of the posterior densities at the current and the proposed new position. If the proposal is rejected, walker j remains at its current position. Once every walker has been updated (j = 1, 2, ..., nwalkers) we move to cycle i+1 and repeat the update step.

The random numbers (the size of the jump z and the uniform variate u used to randomly choose accept/reject) are computed before the loop over walkers begins. This is to make the code a little more clear and efficient.

See Also

gw_sampler, walk_move


svdataman/tonic documentation built on Aug. 2, 2019, 3:21 p.m.