MATLAB File Help: dml.lds View code for dml.lds Default Topics
dml.lds
 lds linear dynamical system. 
 
    DESCRIPTION
    data X is represented as trials x features x timepoints
 
    State can be partially observed/unobserved during training.
    partial observability of multiple observations is also supported
    observations are normally distributed conditional on the state.
    multiple observation sequences are supported
 
    bias term is *NOT* automatically added to the model
 
    K = number of states
    M = number of observations
    T = number of timesteps
 
    X and Y are swapped wrt the Kalman filter conventions
 
    EXAMPLE
    rand('seed',2); randn('seed',2);
  
    nsamples = 1000; ncov = 2; ncycles = 10; ntrials = 2; 
    Y = sin(ncycles * 2 * pi * (1:nsamples) ./ nsamples);
    Y = repmat(reshape(Y,[1 1 numel(Y)]),[ntrials 1 1]);
    X = repmat(Y,[1 ncov 1]) + 0.5*randn(ntrials,ncov,nsamples); 
    
    k = dml.lds('inference','smooth','verbose',true,'indims',[ncov nsamples]);
    k = k.train(X,Y);
    Z = k.test(X);
    figure
    plot(squeeze(Y(1,:,:))','k');
    hold on;
    plot(squeeze(Z(1,:,:))','r');
    legend('real','predicted');
  
    k = dml.lds('verbose',true);
    k = k.train(X,nan(size(Y))); % hidden state estimation
    U = repmat(Y,[1 ncov 1]) + 0.1*randn(ntrials,ncov,nsamples); 
    Z = k.test(U);
    figure
    plot(squeeze(Y(1,:,:))','k--','LineWidth',2);
    hold on;
    plot(zscore(squeeze(Z(1,:,:))'),'r','LineWidth',2);
    plot(squeeze(X(1,:,:))','bo');
    legend('real','predicted','observed');
  
    k = dml.lds('inference','smooth','verbose',true);
    k = k.train(X,[Y nan(size(Y))]); % mixture of hidden + observed states
    U = repmat(Y,[1 ncov 1]) + 0.1*randn(ntrials,ncov,nsamples); 
    Z = k.test(X);
    figure
    plot(zscore(squeeze(Y(1,:,:))'),'k');
    hold on;
    plot(zscore(squeeze(Z(1,:,:))'),'r');
    plot(zscore(squeeze(X(1,:,:))'),'bo');
    legend('real','predicted','observed');
  
    REFERENCES
    Pattern Recognition and Machine Learning, Bishop
    A unifying review of linear dynamical systems, Gharamani 
 
    DEVELOPER
    Marcel van Gerven (m.vangerven@donders.ru.nl)
    Ali Bahramisharif (ali@cs.ru.nl)
Class Details
Superclasses dml.method
Sealed false
Construct on load false
Constructor Summary
lds linear dynamical system.  
Property Summary
A K x K transition matrix for the unobservable state 
C M x K emission matrix for the observations 
Q K x K state noise covariance 
R M x M measurement noise covariance 
V0 K x K the initial hidden noise covariance 
diagQ regularize state noise to diagonal (0 <= diagQ <=1) 
diagR regularize measurement noise to diagonal (0 <= diagR <=1) 
epsilon added to the diagonal of the covariance matrices for numerical stability (e.g. 1e-7); 
indims dimensions of the input data (excluding the trial dim and time dim in time series data) 
inference filter / smooth 
loglik log likelihood 
maxiter maximum number of EM iterations 
mu0 K x 1 the initial mean of the hidden state 
nhidden number of hidden states; automatically determined if Y is given 
restart when false, starts at the previously learned parameters; needed for online learning and grid search 
thresh EM convergence threshold  
verbose whether or not to generate diagnostic output 
Method Summary
protected   Estep  
protected   compute_loglik  
  filter Kalman filter algorithm; returns mean mu and covariance matrix V of 
  likelihood returns log likelihood of a sequence of observations 
  model this method does not return a model 
  smooth Kalman smoother; uses filtered means and variances 
  test LDS inference 
  train resize data if indims is specified