TABLE OF CONTENTS


CMetropolisHastings/AcceptReject [ Functions ]

NAME

    AcceptReject --- accept-reject step for Metropolis-Hastings

FUNCTION

Executes the MH accept-reject decision.

SYNOPSIS

1897 static inline int AcceptReject(double baselik, double candlik, double ratio)

INPUTS

    baselik   loglikelihood of the base case
    candlik   loglikelihood of the candidate
    ratio     additional multiplier (e.g. prior ratio)

OUTPUTS

    out       integer, if 1, accept, if 0, reject

SOURCE

1901 {
1902     if(isnan(candlik)) candlik = -DBL_MAX;
1903     double r = exp(candlik - baselik) * ratio; 
1904     double pAccept = dmin(1,r);
1905     int out;
1906     if(isnan(pAccept)) pAccept = 0;
1907     if(runif(0,1) < pAccept) out = 1;
1908     else out = 0;
1909     return out;
1910 }