lds::EM

lds::EM #

More…

Inherited by lds::gaussian::FitEM, lds::poisson::FitEM

Public Functions #

Name
EM() =default
Constructs a new EMFit type.
EM(size_t n_x, data_t dt, UniformMatrixList< kMatFreeDim2 > && u_train, UniformMatrixList< kMatFreeDim2 > && z_train)
Constructs a new EMFit type.
EM(const Fit & fit0, UniformMatrixList< kMatFreeDim2 > && u_train, UniformMatrixList< kMatFreeDim2 > && z_train)
Constructs a new EMFit type.
virtual ~EM() =default
const Fit & Run(bool calc_dynamics =true, bool calc_Q =true, bool calc_init =true, bool calc_output =true, bool calc_measurement =true, size_t max_iter =100, data_t tol =1e-2)
Runs fitting by Expectation(E)-Maximization(M)
std::tuple< UniformMatrixList< kMatFreeDim2 >, UniformMatrixList< kMatFreeDim2 > > ReturnData()
Returns the input/output data to caller.
const std::vector< Matrix > & x() const
gets estimated state (over time)
const std::vector< Matrix > & y() const
gets estimated output (over time)
const Matrix & sum_E_x_t_x_t() const
gets state-input covariance
const Matrix & sum_E_xu_tm1_xu_tm1() const
gets state-input covariance (t-minus-1)
const Matrix & sum_E_xu_t_xu_tm1() const
gets single lag state-input covariance
size_t n_t_tot()
total number of time samples
const Vector & theta() const
gets parameters updated in M step

Protected Functions #

Name
void Expectation(bool force_common_initial =false)
Expectation step.
void Maximization(bool calc_dynamics =true, bool calc_Q =true, bool calc_init =false, bool calc_output =false, bool calc_measurement =false)
Maximization step.
void MaximizeDynamics()
void MaximizeQ()
void MaximizeInitial()
virtual void MaximizeOutput() =0
virtual void MaximizeMeasurement() =0
void Smooth(bool force_common_initial)
get smoothed estimates
virtual void RecurseKe(Matrix & Ke, Cube & P_pre, Cube & P_post, size_t t) =0
recursively update estimator gain Ke
void Reset()
reset to initial conditions
void InitVars()
Initializes the variables.
Vector UpdateTheta()
updates parameter list, theta

Protected Attributes #

Name
UniformMatrixList< kMatFreeDim2 > u_
input training data
UniformMatrixList< kMatFreeDim2 > z_
measurement training data
std::vector< Matrix > x_
state estimate
std::vector< Cube > P_
state estimate cov
std::vector< Cube > P_t_tm1_
single-lag state covariance
std::vector< Matrix > y_
output estimate
Matrix diag_y_
Matrix sum_E_x_t_x_t_
state covariance (current time)
Matrix sum_E_xu_tm1_xu_tm1_
state-input covariance (t-minus-1)
Matrix sum_E_xu_t_xu_tm1_
single lag state-input covariance
Fit fit_
Vector theta_
data_t dt_
sample period
size_t n_u_
number of inputs
size_t n_x_
number of states
size_t n_y_
number of outputs
size_t n_trials_
number of input/output data sequences
std::vector< size_t > n_t_
number of time steps
size_t n_t_tot_
total number of time steps across trials

Detailed Description #

template <typename Fit >
class lds::EM;


Public Function Details #

EM #

EM() =default

EM #

EM(
    size_t n_x,
    data_t dt,
    UniformMatrixList< kMatFreeDim2 > && u_train,
    UniformMatrixList< kMatFreeDim2 > && z_train
)

Parameters:

  • n_x number of states
  • dt sample period
  • u_train input training data
  • z_train measurement training data

EM #

EM(
    const Fit & fit0,
    UniformMatrixList< kMatFreeDim2 > && u_train,
    UniformMatrixList< kMatFreeDim2 > && z_train
)

Parameters:

  • fit0 initial fit
  • u_train input training data
  • z_train measurement training data

~EM #

virtual ~EM() =default

Run #

const Fit & Run(
    bool calc_dynamics =true,
    bool calc_Q =true,
    bool calc_init =true,
    bool calc_output =true,
    bool calc_measurement =true,
    size_t max_iter =100,
    data_t tol =1e-2
)

Parameters:

  • calc_dynamics [optional] whether to calculate dynamics (A, B)
  • calc_Q [optional] whether to calculate process noise covariance
  • calc_init [optional] whether to calculate initial conditions
  • calc_output [optional] whether to calculate output function
  • calc_measurement [optional] whether to calculate parameters for measurement/observation law
  • max_iter max number of iterations
  • tol convergence tolerance (max fractional abs change)

Return: Fit


ReturnData #

inline std::tuple< UniformMatrixList< kMatFreeDim2 >, UniformMatrixList< kMatFreeDim2 > > ReturnData()

Return: tuple(input data, output data)


x #

inline const std::vector< Matrix > & x() const

y #

inline const std::vector< Matrix > & y() const

sum_E_x_t_x_t #

inline const Matrix & sum_E_x_t_x_t() const

sum_E_xu_tm1_xu_tm1 #

inline const Matrix & sum_E_xu_tm1_xu_tm1() const

sum_E_xu_t_xu_tm1 #

inline const Matrix & sum_E_xu_t_xu_tm1() const

n_t_tot #

inline size_t n_t_tot()

theta #

inline const Vector & theta() const

Protected Function Details #

Expectation #

void Expectation(
    bool force_common_initial =false
)

Parameters:

  • force_common_initial whether to force common initial condition for all trials

Maximization #

void Maximization(
    bool calc_dynamics =true,
    bool calc_Q =true,
    bool calc_init =false,
    bool calc_output =false,
    bool calc_measurement =false
)

Parameters:

  • calc_dynamics [optional] whether to caclulate dynamics (A, B)
  • calc_Q [optional] whether to calculate process noise covariance
  • calc_init [optional] whether to calculate initial conditions
  • calc_output [optional] whether to calculate output function
  • calc_measurement [optional] whether to calculate parameters for measurement/observation law

MaximizeDynamics #

void MaximizeDynamics()

MaximizeQ #

void MaximizeQ()

MaximizeInitial #

void MaximizeInitial()

MaximizeOutput #

virtual void MaximizeOutput() =0

Reimplemented by: lds::gaussian::FitEM::MaximizeOutput, lds::poisson::FitEM::MaximizeOutput


MaximizeMeasurement #

virtual void MaximizeMeasurement() =0

Reimplemented by: lds::gaussian::FitEM::MaximizeMeasurement, lds::poisson::FitEM::MaximizeMeasurement


Smooth #

void Smooth(
    bool force_common_initial
)

Parameters:

  • force_common_initial whether to force common initial conditions

RecurseKe #

virtual void RecurseKe(
    Matrix & Ke,
    Cube & P_pre,
    Cube & P_post,
    size_t t
) =0

Parameters:

  • Ke estimator gain
  • P_pre cov of predicted state est.
  • P_post cov of postior sate est.
  • t time

Reimplemented by: lds::gaussian::FitEM::RecurseKe, lds::poisson::FitEM::RecurseKe


Reset #

void Reset()

InitVars #

void InitVars()

UpdateTheta #

Vector UpdateTheta()

Return: parameter list


Protected Attribute Details #

**u_** #

UniformMatrixList< kMatFreeDim2 > u_;

**z_** #

UniformMatrixList< kMatFreeDim2 > z_;

**x_** #

std::vector< Matrix > x_;

**P_** #

std::vector< Cube > P_;

**P_t_tm1_** #

std::vector< Cube > P_t_tm1_;

**y_** #

std::vector< Matrix > y_;

**diag_y_** #

Matrix diag_y_;

**sum_E_x_t_x_t_** #

Matrix sum_E_x_t_x_t_;

**sum_E_xu_tm1_xu_tm1_** #

Matrix sum_E_xu_tm1_xu_tm1_;

**sum_E_xu_t_xu_tm1_** #

Matrix sum_E_xu_t_xu_tm1_;

**fit_** #

Fit fit_;

**theta_** #

Vector theta_;

**dt_** #

data_t dt_ {};

**n_u_** #

size_t n_u_ {};

**n_x_** #

size_t n_x_ {};

**n_y_** #

size_t n_y_ {};

**n_trials_** #

size_t n_trials_ {};

**n_t_** #

std::vector< size_t > n_t_;

**n_t_tot_** #

size_t n_t_tot_ {};


Updated on 19 May 2022 at 17:16:03 Eastern Daylight Time