alisiahkoohi/Langevin-dynamics

Questions regarding the code for Metropolis-adjusted Langevin

Wenlin-Chen opened this issue · 1 comments

Hi, thanks for the repo! I have three questions regarding the code for Metropolis-adjusted Langevin:

  1. When a proposal is rejected, why is the gradient not reset (i.e., self.grad[1].data = self.grad[0].data)?

    else:
    self.x[1].data = self.x[0].data
    self.P[1].data = self.P[0].data

  2. When computing the density of the proposal distribution, why isP[1] used for both directions? Shouldn't it be P[idx^1]?

    return (-(.25 / self.lr_fn(self.counter)) *
    (self.x[idx] - self.x[idx ^ 1] -
    self.lr_fn(self.counter) * self.grad[idx ^ 1] / self.P[1]) *
    self.P[1]
    @ (self.x[idx] - self.x[idx ^ 1] -
    self.lr_fn(self.counter) * self.grad[idx ^ 1] / self.P[1]))

  3. Why are the rejected samples discarded? Shouldn't MH keep both accepted and rejected samples in the list?

  1. grad[0] represents the gradient in the last accepted sample, and the gradient in the unaccepted sample is not required anymore.
  2. What is meant by "direction"? P[1] (preconditioner) acts as the (squared) covariance of the additive noise distribution at the proposed sample and needed for computing the acceptance ratio.
  3. The rejected samples themselves are not needed but the duplicates of the accepted samples per rejection might be saved. Feel free to submit a pull request with pointers to references in the comments.