Revision 1082, 1.4 kB
(checked in by suzdalev, 14 years ago)
|
multinomial filter
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | classdef mexMultiNomBM < mexBM |
---|
2 | properties |
---|
3 | PYX; % Probability of tran |
---|
4 | PXX; % |
---|
5 | apost_pdf = mexMultiNom; % posterior density in the form of MultiNom |
---|
6 | p0; |
---|
7 | end |
---|
8 | methods |
---|
9 | function obj=validate(obj) % prepare all internal objects for use |
---|
10 | % check alpha |
---|
11 | % check beta |
---|
12 | obj.apost_pdf = mexMultiNom; |
---|
13 | % check p0 |
---|
14 | obj.apost_pdf.p = obj.p0; |
---|
15 | obj.log_evidence = 0; % evidence is not computed! |
---|
16 | end |
---|
17 | |
---|
18 | function dims=dimensions(obj) |
---|
19 | %please fill: dims = [size_of_posterior size_of_data size_of_condition] |
---|
20 | dims = [1,1,0]; % we have: [1d parameters, 1d observations, 1d condition] |
---|
21 | end |
---|
22 | function obj=bayes(obj,yd,cond) % approximate bayes rule |
---|
23 | |
---|
24 | p = obj.apost_pdf.p; |
---|
25 | PYX = obj.PYX; |
---|
26 | PXX = obj.PXX; |
---|
27 | |
---|
28 | nvalx = size(p,1); |
---|
29 | |
---|
30 | k=yd; |
---|
31 | |
---|
32 | %choice from the table for the output |
---|
33 | |
---|
34 | a=PYX(:,k); |
---|
35 | |
---|
36 | |
---|
37 | %non-normalized probability |
---|
38 | for l=1:nvalx |
---|
39 | p(l)=PXX(1:end,l)'*diag(a)*p(:); |
---|
40 | |
---|
41 | end |
---|
42 | |
---|
43 | %normalization |
---|
44 | p(:)=p(:)/sum(p(:)); |
---|
45 | |
---|
46 | obj.apost_pdf.p=p; |
---|
47 | end |
---|
48 | end |
---|
49 | |
---|
50 | end |
---|