simHMM: Simulate states and observations for a Hidden Markov Model

Description Usage Arguments Format Value Author(s) See Also Examples

View source: R/HMM.r

Description

Simulates a path of states and observations for a given Hidden Markov Model.

Usage

1
simHMM(hmm, length)

Arguments

hmm

A Hidden Markov Model.

length

The length of the simulated sequence of observations and states.

Format

Dimension and Format of the Arguments.

hmm

A valid Hidden Markov Model, for example instantiated by initHMM.

Value

The function simHMM returns a path of states and associated observations:

states

The path of states.

observations

The sequence of observations.

Author(s)

Lin Himmelmann <[email protected]>, Scientific Software Development

See Also

See initHMM for instantiation of Hidden Markov Models.

Examples

1
2
3
4
# Initialise HMM
hmm = initHMM(c("X","Y"),c("a","b","c"))
# Simulate from the HMM
simHMM(hmm, 100)

Example output

$states
  [1] "X" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "X" "X" "X" "X" "X" "X" "X"
 [19] "Y" "Y" "X" "X" "X" "X" "Y" "Y" "X" "Y" "X" "X" "X" "Y" "Y" "Y" "Y" "Y"
 [37] "Y" "Y" "Y" "Y" "Y" "X" "X" "Y" "Y" "Y" "Y" "X" "X" "X" "X" "X" "X" "X"
 [55] "Y" "Y" "X" "X" "X" "X" "X" "Y" "Y" "Y" "Y" "Y" "X" "Y" "X" "Y" "Y" "Y"
 [73] "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "X" "X" "Y" "Y" "Y" "Y" "Y" "X" "X"
 [91] "X" "X" "X" "X" "Y" "Y" "Y" "Y" "Y" "Y"

$observation
  [1] "c" "a" "a" "b" "a" "b" "c" "a" "b" "a" "b" "c" "a" "b" "b" "a" "b" "c"
 [19] "c" "c" "b" "a" "c" "c" "c" "b" "a" "a" "b" "c" "b" "a" "c" "a" "a" "a"
 [37] "c" "a" "a" "a" "c" "b" "c" "b" "c" "b" "a" "b" "a" "c" "a" "b" "c" "a"
 [55] "c" "b" "c" "b" "b" "b" "b" "c" "a" "c" "b" "a" "b" "c" "c" "b" "a" "b"
 [73] "c" "c" "c" "a" "a" "c" "c" "a" "c" "b" "a" "a" "b" "b" "c" "a" "a" "b"
 [91] "a" "a" "c" "b" "c" "a" "c" "c" "a" "a"

HMM documentation built on May 29, 2017, 11:45 a.m.