[Reality] Markov/Probability tables added

Michael Dartt mad96@hampshire.edu
Thu, 23 Dec 1999 22:41:18 -0500


I've added a MarkovTable class to twisted.util.  Markov (AKA
"probability") tables basically allow you to determine what state you'll
progress to from your current state.  A simple example is, if possible
types of weather are sunny, raining, windy, and snowing, and it's sunny
right now, what will the weather be next time it has the chance to
change?  Another nifty use is to generate words that, while they may not
be real, are pronounceable--enter in the letters of the alphabet as the
possible states (including punctuation, if you are so inclined), and
then enter the sequences of letters from existing words to fill the
probablility table.  Generate a sequence, and you've got a word that
will at least *sound* like it could be real, even if it isn't.

Below is a table showing a very simple Markov table, with the initial
states as the columns, and the possible states as rows.  The numbers in
the colums are the chances that, from that initial state, one will
progress to the corresponding possible states.  (Divide the value in
each cell by the total of the column's values to get the percent
chance--integer representation is easier for the code.)

one	two	three	four	
0	1	0	0	one
1	2	1	0	two
1	0	0	1	three
0	1	0	0	four

Note that the matrix is square in shape (cells with 0 in them mean that
there's no chance the initial state will lead to that possible state). 
There's also only support for two-dimensional matricies at the moment; I
might change this in the future, but don't hold your breath.  (Though
I'm more likely to do so if I'm swamped with requests or if I find it
particularly useful for myself.)

I think I've documented the code fairly well, so I'm going to stop
here.  If you have any questions, email the list.


--Mike