markov-models/constants.py

31 lines
742 B
Python
Raw Permalink Normal View History

2020-12-10 21:43:15 +00:00
from dataclasses import dataclass
import numpy as np
2020-12-11 21:33:20 +00:00
from math import sqrt
2020-12-10 21:43:15 +00:00
@dataclass(frozen=True) # implements constructor among other boilerplate
2020-12-10 21:43:15 +00:00
class State:
mean: float
variance: float
entry: float # pi
exit: float # eta
2020-12-11 21:33:20 +00:00
@property
def std_dev(self):
return sqrt(self.variance)
2020-12-10 21:43:15 +00:00
state1 = State(1, 1.44, 0.44, 0.02)
state2 = State(4, 0.49, 0.56, 0.03)
observations = [3.8, 4.2, 3.4, -0.4, 1.9, 3.0, 1.6, 1.9, 5.0]
a_matrix = np.array([[0.92, 0.06],
[0.04, 0.93]])
state_transition = np.array([[0, 0.44, 0.56, 0],
[0, 0.92, 0.06, 0.02],
[0, 0.04, 0.93, 0.03],
[0, 0, 0, 0]])