MATLAB Answers

logpdf or pdf in mhsample

19 views (last 30 days)
Abhinav
Abhinav on 1 Dec 2017
Commented: Abhinav on 1 Dec 2017
I am using 'mhsample' function for Metropolis-Hastings sampling from a posterior distribution. I am not sure if I should use pdf or logpdf as input arguments. For example, if the prior is a Gaussian, can I give the 'logpdf' argument instead of 'pdf'. What are the situations in which I should use logpdf? And how does MatLab processes 'logpdf' differently than 'pdf', does it make any difference in my final solution.

  0 Comments

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 1 Dec 2017
The functions that are input arguments to mhsample are probability density functions. If you are actually using the logarithm of the probability density functions as inputs, then specify that with 'logpdf'.
Since you say your prior is gaussian, I'm guessing that that is simply the density (not the log), so you should use 'pdf'.

  3 Comments

Abhinav
Abhinav on 1 Dec 2017
I can always take log of any pdf so that floating point inconsistency doesn't occur. In my case, I am a using multivariate proposal which becomes zero for high dimensions, can taking log help me here?
the cyclist
the cyclist on 1 Dec 2017
I'm not really experienced enough with MH to answer that.
Abhinav
Abhinav on 1 Dec 2017
Oh, Thanks for considering!

Sign in to comment.

Sign in to answer this question.