forked from terejanu/AdaptiveGaussianSumFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.m
executable file
·29 lines (25 loc) · 870 Bytes
/
merge.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
function [x,P] = merge(w,mu,sig)
%
% Get the mean and the covariance of the Gaussian Sum by
% merging all the Gaussian components
%
% x - estimate the mean
% P - estimate the covariance
%
% Gabriel Terejanu ([email protected])
%% ------------------------------------------------------------------------
% init
%--------------------------------------------------------------------------
ngs = length(w); % number of Gaussian components
n = size(mu{1},1); % dimensionality of the state space
x = zeros(n,1);
P = zeros(n,n);
%% ------------------------------------------------------------------------
% compute the mean and the covariance
%--------------------------------------------------------------------------
for j = 1 : ngs
x = x + w(j)*mu{j};
end;
for j = 1 : ngs
P = P + w(j)*(sig{j} + (mu{j}-x)*(mu{j}-x)');
end;