Is there any built in function calculating the value of a gradient of multivariate normal probability density function for a given point?
Edit: found this how to evaluate derivative of function in matlab? but that is not what I am looking for
Edit2: owkay, that's what I'm using http://www.mathworks.co.uk/help/stats/mvnpdf.html case 3, looking for value of derivative with respect to X
Means of multivariate normal distributions, specified as a 1 -by-d numeric vector or an m-by-d numeric matrix. If mu is a vector, then mvnrnd replicates the vector to match the trailing dimension of Sigma . If mu is a matrix, then each row of mu is the mean vector of a single multivariate normal distribution.
X is said to have a multivariate normal distribution (with mean µ and covariance Σ) if every linear combination of its component is normally distributed. We then write X ∼ N(µ,Σ). – µ is an n × 1 vector, E(X) = µ – Σ is an n × n matrix, Σ = Cov(X). f(x) = 1 (2π)n/2|Σ|1/2 exp ( − 1 2 (x − µ)T Σ(x − µ) ) .
You can use [sigma,mu] = robustcov(X) function, where X is your multivariate data, i.e. X = [x1 x2 ... xn] and xi is a column vector data. Then you can use Y = mvnpdf(X,mu,sigma) to get the values of the estimated normal probability density function.
A multivariate normal distribution is a vector in multiple normally distributed variables, such that any linear combination of the variables is also normally distributed.
Might I suggest you check The Matrix Cookbook by Peterson and Pedersen (available for free online - just google it). The analytical solution to your problem is on p39, equation 325 (2008 edition).
We didn't even need Matlab for this one!
EDIT: As YBE implies, perhaps I should include the solution in my answer. So, let p(x) denote the multivariate Gaussian pdf, characterized by mean vector m and covariance matrix S. Then:
dp(x) / dx = -p(x) * S^(-1) * (x - m)
and
d^2p / dx dx' = p(x) * (S^(-1) (x - m)(x - m)' S^(-1) - S^(-1))
If you want a Matlab function, then:
function Gradient = MultNormD1(x, Mu, Sigma)
Gradient = -1 * mvnpdf(x, Mu, Sigma) * (Sigma \ (x - Mu));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With