markov query I have noticed a couple markov implementations in python, but none quite seem to do what i would like. Most seem to do an analysis of some text and create a new text based on that... I think, (sorry i just don't know terminology well) a markov table (or is it called a transition table) to describe how to get from one event to another. So if i have 3 events, say, A, B, and C which can come in any order, a Markov chain describes the probability of what the next event will be using a table. The following table demonstrates a first-order Markov chain. There are three possible states. Either the current event is A, B, or C. For each possible current state, there are three possible next letters. Each row in the table indicates the relative probability of going to the next letter. For example, if you are currently on letter A, there is a 20% chance of repeating letter A, a 50% chance of going to B, and a 30% chance of going to C. Note that the sum of changes for each row is 100% (20 + 50 + 30 = 100).
Current -- next -- next -- next A ----- B ----- C A: 20% -- 50% -- 30% B: 35% -- 25% -- 40% C: 70% -- 14% -- 16% Here the sequence C B and C C would be rare and the sequence C A common. This is a first-order Markov chain, which means that only the current state affects the choice of the next event. A second-order Markov chain would mean that the current state and the last state affect the choice of the next event. A third-order Markov chain would indicate that the current state and the last two states in the sequence will affect the choice of the next state, and so on. Here is an example transition table for a 2nd order Markov chain. Current -- next -- next -- next A ----- B ----- C A A 15% 55% 30% A B 20% 45% 35% A C 60% 30% 10% B A 35% 25% 40% B B 49% 48% 3% B C 60% 20% 20% C A 5% 75% 20% C B 0% 90% 10% C C 70% 14% 16% For example, if the current event is B and the last one was A, then the probability of the next event being A is 20%, B is 45% and C is 35%. The pattern C B A will never occur, and the pattern B B C will occur rarely. Does anyone know of any modules or packages that include markov tables for creating patterns like shown above. P.S. Does any one know first of all whether these are called markov tables, transition tables or probability tables? I am not sure i am referring to this correctly and what the differences would be if any cheers, kp -- http://mail.python.org/mailman/listinfo/python-list