Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@math/loglikelihood_ssm_td.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % | |
3 % Compute log-likelihood in time domain for SSM objects | |
4 % | |
5 % INPUT | |
6 % | |
7 % - in, a vector of input signals aos | |
8 % - out, a vector of output data aos | |
9 % - parvals, a vector with parameters values | |
10 % - parnames, a cell array with parameters names | |
11 % - model, an ssm model | |
12 % - inNames, A cell-array of input port names corresponding to the | |
13 % different input AOs | |
14 % - outNames, A cell-array of output ports to return | |
15 % - Noise, a vector of noise aos | |
16 % - cutbefore, followed by the data samples to cut at the starting of the | |
17 % data series | |
18 % - cutafter, followed by the data samples to cut at the ending of the | |
19 % data series | |
20 % | |
21 % L Ferraioli 10-10-2010 | |
22 % | |
23 % $Id: loglikelihood_ssm_td.m,v 1.1 2011/03/15 16:19:20 miquel Exp $ | |
24 % | |
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
26 function loglk = loglikelihood_ssm_td(xp,in,out,parnames,model,inNames,outNames,Noise,varargin) | |
27 % xn,in,out,noise,model,params,inNames,outNames | |
28 cutbefore = []; | |
29 cutafter = []; | |
30 if ~isempty(varargin) | |
31 for j=1:length(varargin) | |
32 if strcmp(varargin{j},'cutbefore') | |
33 cutbefore = varargin{j+1}; | |
34 end | |
35 if strcmp(varargin{j},'cutafter') | |
36 cutafter = varargin{j+1}; | |
37 end | |
38 end | |
39 end | |
40 | |
41 xp = double(xp); | |
42 fs = out(1).fs; | |
43 | |
44 % set parameters in the model | |
45 evalm = model.setParameters(plist('names',parnames,'values',xp)); | |
46 evalm.keepParameters(); | |
47 evalm.modifyTimeStep(plist('newtimestep',1/fs)); | |
48 | |
49 %%% get expected outputs | |
50 plsym = plist('AOS VARIABLE NAMES',inNames,... | |
51 'RETURN OUTPUTS',outNames,... | |
52 'AOS',in); | |
53 eo = simulate(evalm,plsym); | |
54 | |
55 % %%% get expected noise | |
56 % plsym = plist('AOS VARIABLE NAMES',inNoiseNames,... | |
57 % 'RETURN OUTPUTS',outNames,... | |
58 % 'AOS',inNoise); | |
59 % eon = simulate(evalm,plsym); | |
60 | |
61 %%% get measurement noise | |
62 res = out-eo; | |
63 | |
64 loglk = utils.math.loglikehood_td(res,Noise,'cutbefore',cutbefore,'cutafter',cutafter); | |
65 | |
66 | |
67 | |
68 end |