From 8070dc963753142bb86c4ed698d91fd623ed28e7 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Thu, 28 Sep 2017 15:04:40 -0500 Subject: BNW using Octave instead of Matlab. This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02 --- sourcecodes/bnt-master/Kalman/learning_demo.m | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sourcecodes/bnt-master/Kalman/learning_demo.m (limited to 'sourcecodes/bnt-master/Kalman/learning_demo.m') diff --git a/sourcecodes/bnt-master/Kalman/learning_demo.m b/sourcecodes/bnt-master/Kalman/learning_demo.m new file mode 100644 index 00000000..f44716e7 --- /dev/null +++ b/sourcecodes/bnt-master/Kalman/learning_demo.m @@ -0,0 +1,36 @@ +% Make a point move in the 2D plane +% State = (x y xdot ydot). We only observe (x y). +% Generate data from this process, and try to learn the dynamics back. + +% X(t+1) = F X(t) + noise(Q) +% Y(t) = H X(t) + noise(R) + +ss = 4; % state size +os = 2; % observation size +F = [1 0 1 0; 0 1 0 1; 0 0 1 0; 0 0 0 1]; +H = [1 0 0 0; 0 1 0 0]; +Q = 0.1*eye(ss); +R = 1*eye(os); +initx = [10 10 1 0]'; +initV = 10*eye(ss); + +seed = 1; +rand('state', seed); +randn('state', seed); +T = 100; +[x,y] = sample_lds(F, H, Q, R, initx, T); + +% Initializing the params to sensible values is crucial. +% Here, we use the true values for everything except F and H, +% which we initialize randomly (bad idea!) +% Lack of identifiability means the learned params. are often far from the true ones. +% All that EM guarantees is that the likelihood will increase. +F1 = randn(ss,ss); +H1 = randn(os,ss); +Q1 = Q; +R1 = R; +initx1 = initx; +initV1 = initV; +max_iter = 10; +[F2, H2, Q2, R2, initx2, initV2, LL] = learn_kalman(y, F1, H1, Q1, R1, initx1, initV1, max_iter); + -- cgit 1.4.1