KrisLibrary
1.0.0
|
A model of a temporal sequence consisting of k discrete states each with a gaussian emission probability depending on the prior continuous state. More...
#include <LinearProcessHMM.h>
Public Member Functions | |
LinearProcessHMM (int k, int d) | |
LinearProcessHMM (const GaussianMixtureModel &) | |
int | NumDims () const |
void | Resize (int k, int d) |
void | SetUniformTransitions () |
void | SetUniformExitProbabilities (Real pExit) |
bool | TrainEM (const std::vector< std::vector< Vector > > &examples, Real &tol, int maxIters, int verbose=0) |
Solves the max likelihood model from training data. More... | |
bool | TrainDiagonalEM (const std::vector< std::vector< Vector > > &examples, Real &tol, int maxIters, int verbose=0) |
Real | LogLikelihood (const std::vector< int > &dstates, const std::vector< Vector > &observations) const |
Computes the log likelihood of the time series. | |
Real | LogLikelihood (const std::vector< Vector > &observations) const |
Real | Probability (const Vector &p0, const Vector &prevObs, const Vector &obs) const |
void | Predict (const Vector &p0, Vector &pt, int numsteps=1) const |
void | Update (const Vector &p0, const Vector &prevObs, const Vector &obs, Vector &pobs) const |
void | Filter (const Vector &p0, const Vector &prevObs, const Vector &obs, Vector &pnext) const |
void | ObservationDistribution (const Vector &pt, const Vector &prevObs, GaussianMixtureModel &model) const |
void | MAP (const std::vector< Vector > &observations, std::vector< int > &dstates) const |
Computes the MAP assignment using the Viterbi algorithm. | |
void | Posterior (const std::vector< Vector > &observations, std::vector< Vector > &pstate) const |
void | Posterior (const std::vector< Vector > &observations, std::vector< Vector > &pstate, Matrix &tstate) const |
Public Attributes | |
Vector | discretePrior |
Matrix | transitionMatrix |
std::vector< Gaussian< Real > > | continuousPriors |
std::vector< LinearProcess > | emissionModels |
A model of a temporal sequence consisting of k discrete states each with a gaussian emission probability depending on the prior continuous state.
The graphical model representation is as follows: x0 -> x1 -> ... | | v v o0 -> o1 -> ...
where each P(o[t] | x[t], o[t-1]) is a linear process o[t]=Ao[t-1]+b+err with the coefficients A, b, and error covariance depending on x[t].
void Statistics::LinearProcessHMM::Filter | ( | const Vector & | p0, |
const Vector & | prevObs, | ||
const Vector & | obs, | ||
Vector & | pnext | ||
) | const |
Given prior distribution over previous discrete state p0, the previous observation, and the current observation obs, return the posterior distribution over the current state (shortcut to Predict + Update)
void Statistics::LinearProcessHMM::ObservationDistribution | ( | const Vector & | pt, |
const Vector & | prevObs, | ||
GaussianMixtureModel & | model | ||
) | const |
Given distribution over discrete states and the previous observation, compute distribution over the current observation
References Statistics::GaussianMixtureModel::phi.
void Statistics::LinearProcessHMM::Posterior | ( | const std::vector< Vector > & | observations, |
std::vector< Vector > & | pstate | ||
) | const |
Computes the posterior probabilities of each discrete state using the forward-backward algorithm
void Statistics::LinearProcessHMM::Posterior | ( | const std::vector< Vector > & | observations, |
std::vector< Vector > & | pstate, | ||
Matrix & | tstate | ||
) | const |
Computes the posterior probabilities of each discrete state and accumulates state-to-state transition pairs using the forward-backward algorithm
References Statistics::ExpNormalize(), Math::GaussianCondition(), Math::GaussianMarginalize(), Math::GetElements(), Statistics::Normalize(), Statistics::GaussianMixtureModelRaw::phi, Math::Gaussian< T >::probability(), Math::RandomAllocate(), and Math::SetElements().
void Statistics::LinearProcessHMM::Predict | ( | const Vector & | p0, |
Vector & | pt, | ||
int | numsteps = 1 |
||
) | const |
Given prior distribution over discrete states p0, predicts the distribution after numsteps time steps
bool Statistics::LinearProcessHMM::TrainEM | ( | const std::vector< std::vector< Vector > > & | examples, |
Real & | tol, | ||
int | maxIters, | ||
int | verbose = 0 |
||
) |
Solves the max likelihood model from training data.
Runs expectation-maximization, starting from current values of gaussians, given the training data, a tolerance, # of max iterations. Returns true if tolerance was reached, returns log-likelihood of data in tol.
References Math::IsFinite().
void Statistics::LinearProcessHMM::Update | ( | const Vector & | p0, |
const Vector & | prevObs, | ||
const Vector & | obs, | ||
Vector & | pobs | ||
) | const |
Given prior distribution over current state p0, the previous observation, and the current observation obs, updates the state distribution
References Statistics::ExpNormalize(), and Math::IsInf().