Description Usage Arguments Details Examples
The metropolis algorithm is a special case of the metropolis-hastings algorithm, namely where the proposal distribution is symmetric.
1 2 3 4 5 6 | metropolis <- function(
rproposal,
prob,
niter,
init,
log_prob = FALSE)
|
rproposal |
rproposal(previous_val) generates a value from the proposal distribution |
prob |
prob(val_proposed)/prob(val_t_minus_1) forms the acceptance probability |
niter |
number of iterations to perform |
init |
vector of initial values |
log_prob |
whether or not prob function specifies log probabilities |
This function returns a niter x d matrix of values where d is the dimension of init and the dimension of each element from rproposal. The returned matrix contains all generated values of the metropolis walk.
1 2 3 4 5 6 7 8 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.