Directly computing pdf of distributions often leads to numerical underflow, especially when dealing with high dimensional data. Therefore, the pdf functions provided by Matlab is not very useful for real world problems.
This pack provides numerical stable pdf of popular distributions in log scale, which can be used as building blocks for probabilistic modeling.
Currently this package is now a part of the PRML toolbox (http://www.mathworks.com/matlabcentral/fileexchange/55826-pattern-recognition-and-machine-learning-toolbox).
Mo Chen (2019). Log Probability Density Function (PDF) (https://www.mathworks.com/matlabcentral/fileexchange/55831-log-probability-density-function-pdf), MATLAB Central File Exchange. Retrieved .
Correcting a typo:
The calculated log-scale density does not always match calculations using R's dnorm().
logGauss(7,8,10) = -2.120231079701695
Whereas in R, dnorm(7,8,10,log=TRUE) = -3.226524
Yet logGauss and dnorm can return identical values
logGauss(2,1,1) = dnorm(2,1,1,log=TRUE) = -1.418938533204673
I further note that logGauss does not have the same functionality as MATLAB's normpdf(x,mu,sigma). If you have vector x and vector mu, but scalar sigma, then you need to create a matrix for sigma. It might look like this diag(repmat(sigma,[length(x),1])). This is not necessary with normpdf(x,mu,sigma).
Inspired by: Pattern Recognition and Machine Learning Toolbox