Skip to content

Instantly share code, notes, and snippets.

@beaucronin
Created October 3, 2011 00:55
Show Gist options
  • Save beaucronin/1258210 to your computer and use it in GitHub Desktop.
Save beaucronin/1258210 to your computer and use it in GitHub Desktop.
Metropolis sampler pseudocode
x = initial()
prob = target_dist(x)
for i in range(steps):
x_star = propose(x)
prob_star = target_dist(x)
if prob_star > prob or random() < prob_star / prob:
x = x_star
prob = prob_star
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment