PoisHmm object

struct PoisHmm

The PoisHmm structure encapsulates all data of a Hidden-Markov model with Poisson-distributed states.

typedef struct PoisHmm {
    bool err;
    size_t n_obs;
    size_t m_states;
    size_t n_iter;
    size_t max_iter;
    scalar tol;
    scalar aic;
    scalar bic;
    scalar llh;
    PoisParams *init;
    PoisParams *params;
    PoisProbs *probs;
} PoisHmm;
bool err

A boolean error indicator. err equals true if an error occurred during fitting.

size_t n_obs

An integral number greater than zero that specifies the number of states in an HMM.

size_t m_states

An integral number that specifies the number of observations, that is, the length of the input data set.

size_t n_iter

An integral number specifying the number of the iterations it took the fitting algorithm to converge. If it did not converge, this is equal to max_iter.

size_t max_iter

An positive integral number specifying the maximum number of iterations of the EM algorithm.

scalar tol

An floating point number specifying the update tolerance of the fitting algorithm. An computed update is only applied if the update score is greater than tol.

scalar aic

Storage for the Akaike Information Criterion of the fitted model.

scalar bic

Storage for the Bayseian Information Criterion of the fitted model.

scalar llh

Storage for the log likelihood of the fitted model.

PoisParams *init

Pointer to initial model parameters.

PoisParams *params

Pointer to estimated model parameters.

PoisProbs *probs

Pointer to computation buffers.

Object creation

PoisHmm *PoisHmm_New(const size_t n_obs, const size_t m_states)

Allocate memory for a new PoisHmm structure.

PoisHmm_Delete(this)

Delete a PoisHmm struct from memory.

Initialization

void PoisHmm_Init(PoisHmm *restrict const this, const scalar *restrict const lambda, const scalar *restrict const gamma, const scalar *restrict const delta)

Initialize the parameters of a PoisHmm structure with starting values.

void PoisHmm_InitRandom(PoisHmm *restrict const this)

Initialize the parameters of a PoisHmm with a random parameters.

Operations

All operations require a properly initialized PoisHmm structure as first parameter.

void PoisHmm_EstimateParams(PoisHmm *restrict const this, const DataSet *restrict const inp)

Compute maximum-likelihood estimates for the HMM parameters given the data set pointed to by inp. Estimates are computed using the Baum-Welch algorithm.

During the fit, keep the members n_iter, llh, params, and probs up to date. This information may be used for further processing, such as model checking or, in case of errors, debugging at any time.

Also, set the error indicator to true if the fit or any intermediate computation fails.

int PoisHmm_ForwardBackward(PoisHmm *restrict const this)

Compute the forward and backward probabilities of the HMM using the forward-backward algorithm.

int PoisHmm_ForwardProbabilities(PoisHmm *restrict const this)

Compute only the forward probabilities under the HMM.

int PoisHmm_BackwardProbabilities(PoisHmm *restrict const this)

Compute only the backward probabilities under the HMM.

void PoisHmm_LogLikelihood(PoisHmm *restrict const this)

Compute the logarithm of the data likelihood under the HMM.

void PoisHmm_LogCondStateProbs(PoisHmm *restrict const this)

Compute the logarithm of the conditional state probabilities.

Utilities

void PoisHmm_Summary(const PoisHmm *restrict const this)

Print estimated parameters and quality measures to stderr.