Learn R Programming

mlpack (version 4.6.0)

hmm_generate: Hidden Markov Model (HMM) Sequence Generator

Description

A utility to generate random sequences from a pre-trained Hidden Markov Model (HMM). The length of the desired sequence can be specified, and a random sequence of observations is returned.

Usage

hmm_generate(
  length,
  model,
  seed = NA,
  start_state = NA,
  verbose = getOption("mlpack.verbose", FALSE)
)

Value

A list with several components:

output

Matrix to save observation sequence to (numeric matrix).

state

Matrix to save hidden state sequence to (integer matrix).

Arguments

length

Length of sequence to generate (integer).

model

Trained HMM to generate sequences with (HMMModel).

seed

Random seed. If 0, 'std::time(NULL)' is used. Default value "0" (integer).

start_state

Starting state of sequence. Default value "0" (integer).

verbose

Display informational messages and the full list of parameters and timers at the end of execution. Default value "getOption("mlpack.verbose", FALSE)" (logical).

Author

mlpack developers

Details

This utility takes an already-trained HMM, specified as the "model" parameter, and generates a random observation sequence and hidden state sequence based on its parameters. The observation sequence may be saved with the "output" output parameter, and the internal state sequence may be saved with the "state" output parameter.

The state to start the sequence in may be specified with the "start_state" parameter.

Examples

Run this code
# For example, to generate a sequence of length 150 from the HMM "hmm" and
# save the observation sequence to "observations" and the hidden state
# sequence to "states", the following command may be used: 

if (FALSE) {
output <- hmm_generate(model=hmm, length=150)
observations <- output$output
states <- output$state
}

Run the code above in your browser using DataLab