root/applications/bdmtoolbox/mex/mex_classes/mexLaplaceBM.m @ 983

Revision 983, 1.9 kB (checked in by smidl, 14 years ago)

doc - extensions

Line 
1classdef mexLaplaceBM < mexBM
2    % Approximate Bayesian estimator of parameters of Laplace distributed observation.
3    % Maximum likelihood approximation of the Bayes rule is used, posterior is in the form of dirac.
4    properties
5        max_window_length = 10;                               % max window length (default = 10)
6        data_window =[];                                      % sliding window of data
7    end
8    methods
9        function obj=validate(obj)                            % prepare all internal objects for use
10            obj.apost_pdf = mexDirac;
11            obj.apost_pdf.point = [0;0];
12            obj.log_evidence = 0;                             % evidence is not computed!
13            disp('val');
14        end
15
16        function dims=dimensions(obj)
17            %please fill: dims = [size_of_posterior size_of_data size_of_condition]
18            dims = [2,1,0]                                    % we have: [2d parameters, 1d observations, 0d condition]
19        end
20        function obj=bayes(obj,dt,cond)                       % approximate bayes rule
21            if size(obj.data_window,2)>=obj.max_window_length
22                obj.data_window = [dt obj.data_window(1:end-1)];
23            else
24                obj.data_window = [dt obj.data_window];
25            end
26            % transform old estimate into new estimate
27            m_hat = mean(obj.data_window);
28            b_hat = sum(abs(obj.data_window-m_hat))/ size(obj.data_window,2);
29            obj.apost_pdf.point = [m_hat; b_hat];             % store result in psoterior pdf
30        end
31        function p=epredictor(obj,cond)                       % when predictive density is needed approximate it by Laplace with point estimates
32            % return predictive density (max likelihood)
33            p = mexLaplace;
34            p.mu = obj.apost_pdf.point(1);
35            p.b  = obj.apost_pdf.point(2);
36            p=p.validate;
37        end
38    end
39
40end
Note: See TracBrowser for help on using the browser.