root/applications/bdmtoolbox/mex/mex_classes/mexGaussMergerArit.m @ 1093

Revision 1087, 1.4 kB (checked in by smidl, 14 years ago)

mex Mergers

Line 
1%> @file mexMerger.m
2%> @brief File mapping root class of Mergerbase from BDM
3% ======================================================================
4%> @brief Abstract class of Bayesian Model (estimator), bdm::BM
5%
6%> This class provides a bridge between bdm::MergerBase and Matlab
7% ======================================================================
8classdef mexGaussMergerArit < mexMerger
9    methods
10        %> check consistency of the object and fill defaults
11        function obj=validate(obj)
12            if length(obj.sources)<1
13                error('No sources to merge');
14            end
15           
16            obj.merger= struct('class','egauss');
17        end
18       
19       
20        %> Merge sources into the merger
21        function obj=merge(obj)
22            Cov = epdf_covariance(obj.sources{1});
23            mea = epdf_mean(obj.sources{1});
24           
25            Mom1 = obj.weights(1)*mea;
26            Mom2 = obj.weights(1)*(Cov+mea*mea');
27            for i=2:length(obj.sources)
28                Cov = epdf_covariance(obj.sources{i});
29                mea = epdf_mean(obj.sources{i});
30               
31                Mom1 = Mom1+ obj.weights(i)*mea;
32                Mom2 = Mom2 + obj.weights(i)*(Cov+mea*mea');
33            end
34            obj.merger.mu = Mom1;
35            obj.merger.R = Mom2 - Mom1*Mom1';
36            % transform old estimate into new estimate
37        end
38    end
39end
Note: See TracBrowser for help on using the browser.