Description Usage Arguments Value Author(s) Examples
Implements Metropolis sampling for an arbitrary discrete probability distribution
1 | random_walk(pd, start, num_steps)
|
pd |
function containing discrete probability function on the integers 1, 2, ... |
start |
starting value of algorithm |
num_steps |
number of iterations of algorithm |
A vector of simulated values
Jim Albert
1 2 3 4 5 6 7 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.