1 | classdef 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 |
---|
6 | data_window =[]; % estimate of mu is median of observations |
---|
7 | end |
---|
8 | methods |
---|
9 | function obj=validate(obj) |
---|
10 | % prepare all internal objects for use |
---|
11 | obj.apost_pdf = mexDirac; |
---|
12 | obj.apost_pdf.point = [0;0]; |
---|
13 | obj.log_evidence = 0; % evidence is not computed! |
---|
14 | disp('val'); |
---|
15 | end |
---|
16 | |
---|
17 | function dims=dimensions(obj) |
---|
18 | %please fill |
---|
19 | %dims = [size_of_posterior size_of_data size_of_condition] |
---|
20 | dims = [2,1,0] % we have: [2d parameters, 1d observations, 0d condition] |
---|
21 | end |
---|
22 | function obj=bayes(obj,dt,cond) |
---|
23 | if size(obj.data_window,2)>=obj.max_window_length |
---|
24 | obj.data_window = [dt obj.data_window(1:end-1)]; |
---|
25 | else |
---|
26 | obj.data_window = [dt obj.data_window]; |
---|
27 | end |
---|
28 | % transform old estimate into new estimate |
---|
29 | m_hat = mean(obj.data_window); |
---|
30 | b_hat = sum(abs(obj.data_window-m_hat))/ size(obj.data_window,2); |
---|
31 | obj.apost_pdf.point = [m_hat; b_hat]; |
---|
32 | end |
---|
33 | function p=epredictor(obj,cond) |
---|
34 | % return predictive density (max likelihood) |
---|
35 | p = mexLaplace; |
---|
36 | p.mu = obj.apost_pdf.point(1); |
---|
37 | p.b = obj.apost_pdf.point(2); |
---|
38 | p=p.validate; |
---|
39 | end |
---|
40 | end |
---|
41 | |
---|
42 | end |
---|