Skip to main content
. 2020 Feb 24;22(2):258. doi: 10.3390/e22020258
Algorithm A1 The Metropolis-Hastings Markov chain Monte Carlo (MH-MCMC) algorithm
  • 1:

    Input: Prior p(θ), stepsize γ, maximum number of iterations Niter.

  • 2:

    Initialize:θ(0)p(θ).

  • 3:

    for i=1,2,,Niter do

  • 4:

        Propose: θcand=θ(i1)+γN(0,I).

  • 5:

        Acceptance Probability:

  • 6:

        α(θcand|θ(i1))=min1,p(θcand|D)p(θ(i1)|D).

  • 7:

        Draw uU(0,1).

  • 8:

        if u<α then

  • 9:

            Accept the proposal: θ(i)θcand.

  • 10:

        else

  • 11:

            Reject the proposoal: θ(i)θ(i1).

  • 12:

        end if

  • 13:

    end for