2%> Return the corresponding natural logarithm(s) of Probability Density Function (PDF)
3%> of the input ``ndim``-dimensional multivariate Normal random vector(s).<br>
6%> This log-PDF function can be potentially faster and more flexible than the intrinsic MATLAB
7%> equivalent because it optionally accepts vectors of MVN random variates and returns the
8%> natural logarithm of the density function
which avoids a costly exponentiation.<br>
10%> \param[in] x : The input vector of shape ``[ndim, nvec]`` of MATLAB ``real``,
11%> representing the set of ``nvec`` MVN vectors from the ``ndim``-dimensional MVN space.<br>
12%> \param[in] mean : The input vector of shape ``[ndim, 1]`` of MATLAB ``real``,
13%> representing the mean of a Multivariate Normal
14%> distribution in ``size(mean)`` dimensional space.<br>
15%> If the input value is empty, it is set to the
default value.<br>
16%> (**optional**.
default = ``zeros(ndim, 1)``.)
17%> \param[in] invcov : The input positive-definite square matrix of shape ``[ndim, ndim]`` of MATLAB ``real``,
18%> representing the inverse of the covariance matrix of the target Multivariate
19%> Normal distribution in ``numel(mean)`` dimensional space.<br>
20%> If the input value is empty, it is set to the
default value.<br>
21%> Note that the inverse covariance matrix can be readily obtained from
22%> its lower or upper Cholesky factorization (``cholow`` or ``choupp``) via
23%> [pm.matlab.inv(cholow)](@ref
inv) or [pm.matlab.inv(choupp
')](@ref inv).<br>
24%> (**optional**. default = ``eye(ndim, ndim)``.)
27%> ``logPDF`` : The output column vector of MATLAB ``real`` of shape ``[nvec, 1]``
28%> containing the natural logarithm(s) of the input MVN vector(s).<br>
30%> \interface{getLogPDF}
33%> logPDF = pm.stats.dist.mvn.getLogPDF(x)
34%> logPDF = pm.stats.dist.mvn.getLogPDF(x, mean)
35%> logPDF = pm.stats.dist.mvn.getLogPDF(x, [], invcov)
36%> logPDF = pm.stats.dist.mvn.getLogPDF(x, mean, invcov)
41%> \include{lineno} example/stats/dist/mvn/getLogPDF/main.m
43%> \include{lineno} example/stats/dist/mvn/getLogPDF/main.out.m
45%> \image html example/stats/dist/mvn/getLogPDF/mvn.getLogPDF.scatter.3d.png width=700
50%> \JoshuaOsborne, May 21 2024, 12:06 AM, University of Texas at Arlington<br>
51%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
52%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
53function logPDF = getLogPDF(x, mean, invcov)
64 invcov = eye(ndim, ndim);
66 logDetInvCov = log(det(invcov));
69 mean = zeros(ndim, 1);
73 logPDF = zeros(nvec, 1);
74 log2pi = 1.837877066409345; % log(2 * pi)
75 logNormFac = -0.5 * (ndim * log2pi - logDetInvCov);
77 xnormed = x(:, ivec) - mean;
78 logPDF(ivec) = logNormFac - .5 * (xnormed' * invcov * xnormed);
function getLogPDF(in x, in kappa, in invOmega, in invSigma)
Return the corresponding natural logarithm(s) of Probability Density Function (PDF) of the input rand...
function inv(in cholow)
Generate and return the inverse of a positive-definite matrix whose Lower-triangular Cholesky factori...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...