Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate derivative of multivariate normal probability density function

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

like image 701
Karusmeister Avatar asked Nov 08 '12 23:11

Karusmeister


People also ask

What is Mvnrnd Matlab?

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.

How do you calculate covariance matrix 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 − µ) ) .

How do you fit a multivariate normal distribution in Matlab?

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.

What do you mean by multivariate normal distribution?

A multivariate normal distribution is a vector in multiple normally distributed variables, such that any linear combination of the variables is also normally distributed.


1 Answers

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));
like image 155
Colin T Bowers Avatar answered Oct 05 '22 23:10

Colin T Bowers