Learn R Programming

tileHMM (version 1.0-7)

sampleSeq: Generate Observation Sequence from HMM

Description

Generates an observation sequence according to a model given as object of class hmm. Optionally the undelying state sequence is returned together with the observations.

Usage

"sampleSeq"(hmm, size, return.states=FALSE)

Arguments

hmm
Object of class contHMM.
size
Numeric value indicating the desired length of the observation sequence.
return.states
Logical indicating whether the underlying state sequence should be returned together with the observation sequence.

Value

If return.states is FALSE (the default) a vector of length size with observations sampled from hmm. If return.states is TRUE a list with components
states
Character vector with state sequence that was used to generate the observations.
observation
Vector with observations sampled from hmm.

See Also

hmm, states

Examples

Run this code
## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.035, 0.01)
location <- c(1, 2)
scale <- c(1, 1)
df <- c(4, 6)
hmm1 <- getHMM(list(a=transition, mu=location, sigma=scale, nu=df),
    state.names)

## generate observation sequence from model
obs <- sampleSeq(hmm1, 100)

Run the code above in your browser using DataLab