Created
November 13, 2018 15:21
-
-
Save pfmoore/f3eb2a1db421a40b56010c76b4d34bd8 to your computer and use it in GitHub Desktop.
Lea snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lea | |
from lea import markov | |
lea_obj = lea.vals('abcde') | |
ch = markov.chain_from_seq('abgdkjhagbdffagg') | |
# To get the probability distribution from an Alea object: | |
probs = list(zip(lea_obj.support, lea_obj.ps)) | |
# To get the transition matrix from a Markov chain object: | |
for state, tr in ch._next_state_lea_per_state: | |
for dest, prob in zip(tr.support, tr.ps): | |
print(f"{state}->{dest}: {prob}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment