Skip to content
Discussion options

You must be logged in to vote

You can replace your if statement with a where statement:

def accept_or_not(self, p):
  uni = jnp.asarray(np.random.uniform(low=0, high=1))
  return jnp.where(uni < p, True, False)

or, even more simply for this particular case (since you're just returning True or False you could do this:

def accept_or_not(self, p):
  uni = jnp.asarray(np.random.uniform(low=0, high=1))
  return uni < p

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@yiminghwang
Comment options

@jakevdp
Comment options

@yiminghwang
Comment options

Answer selected by yiminghwang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants