-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgauss_mix_eval.m
31 lines (27 loc) · 1.02 KB
/
gauss_mix_eval.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
function [ result ] = gauss_mix_eval( mu, SIGMA, x )
% Evaluate the unweighted gaussian mixture probability density function
%
% Evaluate the gaussian mixture probability density function given by the
% centers mu and the corresponding covariance matrices SIGMA at
% position(s) x
%
% mu is a p-by-d matrix where each of the p rows represents the
% (d-dimensional) position of a center
%
% SIGMA is a p-by-d-by-d array where SIGMA(j,:,:) is the d-by-d
% covariance matrix corresponding to the j-th center. A valid
% covariance matrix must be positive-semidefinite. There will
% be no warning when the passed matrices aren't.
%
% x n-by-d array where each of the n rows represents a position
% where the function shall be evaluated
%
% See also: gauss, plot_gauss_mix
p = size(mu,1);
n = size(x,1);
result = 0;
for j=1:p
result = result + gauss(x, repmat(mu(j,:), [n 1]), squeeze(SIGMA(j,:,:)));
end
result = result / p;
end