random_walk {ProbBayes} | R Documentation |
Metropolis sampling of a discrete distribution
Description
Implements Metropolis sampling for an arbitrary discrete probability distribution
Usage
random_walk(pd, start, num_steps)
Arguments
pd |
function containing discrete probability function on the integers 1, 2, ... |
start |
starting value of algorithm |
num_steps |
number of iterations of algorithm |
Value
A vector of simulated values
Author(s)
Jim Albert
Examples
# random walk through a binomial distribution
pd <- function(x){
dbinom(x, size = 10, prob = 0.5)
}
start <- 4
num_steps <- 50
out <- random_walk(pd, start, num_steps)
[Package ProbBayes version 1.1 Index]