Skip to content

Instantly share code, notes, and snippets.

@pfmoore
Created November 13, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfmoore/f3eb2a1db421a40b56010c76b4d34bd8 to your computer and use it in GitHub Desktop.
Save pfmoore/f3eb2a1db421a40b56010c76b4d34bd8 to your computer and use it in GitHub Desktop.
Lea snippets
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