himamo v0.1.0 Himamo.Sim
Defines the required functions to simulate a model.
Example
iex> # State transition probabilities - ensure the model transitions at
...> # each step.
...> a = fn ->
...> import Himamo.Model.A, only: [new: 1, put: 3]
...> new(2)
...> |> put({0, 0}, 0.0) |> put({0, 1}, 1.0)
...> |> put({1, 0}, 1.0) |> put({1, 1}, 0.0)
...> end.()
...>
...> # Symbol emission probabilities - model always emits symbol 0 when
...> # in state 0 and symbol 1 when in state 1.
...> b = fn ->
...> import Himamo.Model.B, only: [new: 1, put: 3]
...> new(n: 2, m: 2)
...> |> put({0, 0}, 1.0) |> put({0, 1}, 0.0)
...> |> put({1, 0}, 0.0) |> put({1, 1}, 1.0)
...> end.()
...> model = %Himamo.Model{
...> n: 2, m: 2,
...> a: a, b: b,
...> pi: Himamo.Model.Pi.new([1.0, 0.0]), # Start in state 0
...> }
...>
...> # Generate 5 symbols:
...> Himamo.Sim.simulate(model, 5)
[0, 1, 0, 1, 0]
Summary
Functions
Simulate given model emitting count symbols