MATLAB: How to prevent underflow of MVNPDF in Statistics Toolbox 6.0 (R2007a)

Statistics and Machine Learning Toolbox

I want to prevent underflow in MVNPDF in Statistics Toolbox 6.0 (R2007a). Currently MVNPDF returns exp(loglikelihood), the exponent of the log likelihood function, but that value can easily underflow.

Best Answer

This feature is not available in Statistics Toolbox 6.0 (R2007a). However, the function can be modified as follows.
Split the last line of the function into two steps:
logl = -0.5*quadform - logSqrtDetSigma - d*log(2*pi)/2;
y = exp(logl);
and change the function signature
function [y logl] = mvnpdf(X, Mu, Sigma)