-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmvnpdfcomplex.m
46 lines (40 loc) · 1.13 KB
/
mvnpdfcomplex.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function y = mvnpdfcomplex(X, MU, SIGMA)
% Function: mvnpdfcomplex
%
% y = mvnpdfcomplex(X, MU, SIGMA)
%
% Author: Irene Santos Velázquez
%
% Contact: [email protected], [email protected]
%
% Created 7/03/2017
%
% Description: This function computes the multivariate normal probability
% density function (pdf) with mean MU and covariance SIGMA, evaluated at
% each row of X (where X is a matrix with complex numbers)
%
% Inputs:
% X is a N-by-D complex matrix where the rows correspond to points and
% columns correspond to variables. The pdf will be evaluated at these
% points.
% MU is a N-by-D matrix with the complex mean
% SIGMA is a D-by-D matrix with the variances.
%
% Output:
% y is a N-by-1 vector with the pdf
% Get size of data. Column vectors provisionally interpreted as multiple scalar data.
[N,D] = size(X);
% Checking if SIGMA is diagonal
if isdiag(SIGMA)
sigmaIsDiag = true;
else
sigmaIsDiag = false;
end
if sigmaIsDiag
sigmaInv=diag(1./diag(SIGMA));
detSigma=prod(diag(SIGMA));
else
sigmaInv=SIGMA\eye(length(SIGMA));
detSigma=det(SIGMA);
end
y=exp(-ctranspose(X-MU)*sigmaInv*(X-MU))./(pi^N*detSigma);