Created
January 23, 2012 13:47
-
-
Save ptn/1663209 to your computer and use it in GitHub Desktop.
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
class MarkovChain | |
def initialize(states, transitions=nil) | |
@states = states | |
@graph = empty_graph | |
@transitions = build_transitions(transitions) if transitions | |
end | |
def transitions=(transitions) | |
@graph = empty_graph | |
@transitions = build_transitions(transitions) if transitions | |
end | |
private | |
def build_transitions(transitions) | |
count_transitions transitions | |
normalize transitions | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment