hmm_generate: Hidden Markov Model (HMM) Sequence Generator

View source: R/hmm_generate.R

hmm_generateR Documentation

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 = FALSE)

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 "FALSE" (logical).

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.

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).

Author(s)

mlpack developers

Examples

# 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: 

## Not run: 
output <- hmm_generate(model=hmm, length=150)
observations <- output$output
states <- output$state

## End(Not run)

mlpack documentation built on Oct. 29, 2022, 1:06 a.m.

Related to hmm_generate in mlpack...