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

Revision 988, 2.0 kB (checked in by smidl, 14 years ago)

doc

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        end
14
15        function dims=dimensions(obj)
16            %please fill: dims = [size_of_posterior size_of_data size_of_condition]
17            dims = [2,1,0]                                    % we have: [2d parameters, 1d observations, 0d condition]
18        end
19        function obj=bayes(obj,dt,cond)                       % approximate bayes rule
20            if size(obj.data_window,2)>=obj.max_window_length
21                obj.data_window = [dt obj.data_window(1:end-1)];
22            else
23                obj.data_window = [dt obj.data_window];
24            end
25            % transform old estimate into new estimate
26            m_hat = mean(obj.data_window);
27            b_hat = sum(abs(obj.data_window-m_hat))/ size(obj.data_window,2);
28            obj.apost_pdf.point = [m_hat; b_hat];             % store result in psoterior pdf
29        end
30        function p=epredictor(obj,cond)                       % when predictive density is needed approximate it by Laplace with point estimates
31            % return predictive density (max likelihood)
32            p = mexLaplace;
33            p.mu = obj.apost_pdf.point(1);
34            p.b  = obj.apost_pdf.point(2);
35                                % do not forget to validate
36            p=p.validate;
37                                % assign descriptions
38                                p.rv = yrv;
39                                % rvc is empty be default
40        end
41    end
42
43end
Note: See TracBrowser for help on using the browser.