Skip to content

Instantly share code, notes, and snippets.

@mjrosenb
Created January 25, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjrosenb/32606187fb8bf338d9f8 to your computer and use it in GitHub Desktop.
Save mjrosenb/32606187fb8bf338d9f8 to your computer and use it in GitHub Desktop.
import random
def Q(xs):
return [gauss(x,1) for x in xs]
def next(F, x):
x_ = Q(x)
Fx_ = F(x_)
Fx = F(x)
if Fx_ > Fx:
return x_
a = Fx_ / Fx
if random.random() < a:
return x_
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment