Skip to content

Commit

Permalink
Update hmm.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhushan committed Jul 24, 2023
1 parent b351c04 commit c71481c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sequence_modelling/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ def __init__(self, A, O):
self.logA = np.log(A)

def __repr__(self):
n = "" + "nStates: %d\n" % (self.K)
a = "" + "A:\n %s" % (str(np.exp(self.logA[:-1])))
pi = "" + "\nPi: \n %s" % (str(np.exp(self.logA[-1])))
o = "" + "\nObservation distribution: \n %s" % self.O
return n + a + pi + o
return (
f"nStates: {self.K}\n"
f"A:\n {self.logA[:-1].round(2)}\n"
f"Pi: \n {self.logA[-1].round(2)}\n"
f"Observation distribution: \n {self.O}"
)

def sample(self, dim=1, N=1000):
"""Generates an observation sequence of length N.
Expand Down

0 comments on commit c71481c

Please sign in to comment.