File Exchange

image thumbnail

Log Probability Density Function (PDF)

version 1.0.0.0 (4.01 KB) by Mo Chen
numerically stable pdf of popular distributions in log scale.

4 Downloads

Updated 13 Mar 2016

View License

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).

Cite As

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 .

Comments and Ratings (1)

Matt Falcy

Correcting a typo:

The calculated log-scale density does not always match calculations using R's dnorm().

For example,
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).

Updates

1.0.0.0

update title

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Pattern Recognition and Machine Learning Toolbox