Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
markov.Markov Class Reference

List of all members.

Public Member Functions

def __init__
def add
def put
def get

Public Attributes

 histsize
 choice
 trans

Detailed Description

Definition at line 7 of file markov.py.


Constructor & Destructor Documentation

def markov.Markov.__init__ (   self,
  histsize,
  choice 
)

Definition at line 8 of file markov.py.

00008 
00009     def __init__(self, histsize, choice):
00010         self.histsize = histsize
00011         self.choice = choice
00012         self.trans = {}

Here is the caller graph for this function:


Member Function Documentation

def markov.Markov.add (   self,
  state,
  next 
)

Definition at line 13 of file markov.py.

00013 
00014     def add(self, state, next):
00015         self.trans.setdefault(state, []).append(next)

Here is the call graph for this function:

Here is the caller graph for this function:

def markov.Markov.get (   self)

Definition at line 24 of file markov.py.

00024 
00025     def get(self):
00026         choice = self.choice
00027         trans = self.trans
00028         n = self.histsize
00029         seq = choice(trans[None])
00030         while True:
00031             subseq = seq[max(0, len(seq)-n):]
00032             options = trans[subseq]
00033             next = choice(options)
00034             if not next:
00035                 break
00036             seq += next
00037         return seq
00038 

Here is the caller graph for this function:

def markov.Markov.put (   self,
  seq 
)

Definition at line 16 of file markov.py.

00016 
00017     def put(self, seq):
00018         n = self.histsize
00019         add = self.add
00020         add(None, seq[:0])
00021         for i in range(len(seq)):
00022             add(seq[max(0, i-n):i], seq[i:i+1])
00023         add(seq[len(seq)-n:], None)

Here is the call graph for this function:


Member Data Documentation

Definition at line 10 of file markov.py.

Definition at line 9 of file markov.py.

Definition at line 11 of file markov.py.


The documentation for this class was generated from the following file: