# Markov-Chain transition probabilities for 3 variables

I am a bit confused as I need to calculate the Markov-Chain transition probabilites for 3 variables.

Example data, let's assume a sequence of letters at specific and progressively-constant time steps:

Q
Q
E
Q
C
C
E


What are my transitional probabilities?

My (wrong) understanding is:

P(Q|Q) = 1
P(Q|E) = 1
P(Q|C) = 0

P(E|E) = 0
P(E|C) = 1
P(E|Q) = 1

P(C|C) = 1
P(C|E) = 0
P(C|Q) = 1


And therefore my (wrong) transition matrix will be:

   Q   E   C
Q  1   1   1
E  1   0   0
C  0   1   1


note row sums are not = 1

What am I missing? The same approach works with 2 variables and here it seems that I need to divide each row by the number of probabilities > 0 to make the row sums =1.

Thanks

I'll give one example and hopefully it will be evident how it can be applied to the rest:

$P(X(t) = E | X(t-1) = Q)$ can be estimated empirically as "the percentage of instances of Q that are followed by E". So in this case, there are 3 instances of Q, one of which is followed by an instance of E, meaning that $P(X(t) = E | X(t-1) = Q)$ is equal to 1/3.

Side note: I think when you write P(E|Q), you mean the expression I wrote above, but it's probably better to write it how I did just to be clear that you mean "the probability of E coming directly after Q".

In any Transition Probability Matrix, the row sum must be equal to 1. Your Probabilities are incorrect. It should be

P(Q|Q) = 1/3
p(Q|E) = 1
P(Q|C) = 0

P(E|E) = 0
P(E|C) = 1/2
P(E|Q) = 1/3

P(C|C) = 1/2
P(C|E) = 0
P(C|Q) = 1/3


Hence the Transition Probability Matrix becomes :

   Q    E    C
Q  1/3  1/3  1/3
E  1    0    0
C  0    1/2  1/2
{"ft_lang_label":"__label__en","ft_lang_prob":0.90137494,"math_prob":0.99838793,"size":666,"snap":"2023-40-2023-50","text_gpt3_token_len":239,"char_repetition_ratio":0.12084592,"word_repetition_ratio":0.0,"special_character_ratio":0.3243243,"punctuation_ratio":0.050955415,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999523,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-01T01:22:12Z\",\"WARC-Record-ID\":\"<urn:uuid:22d8505b-af47-428c-a4f4-455f6a638ffc>\",\"Content-Length\":\"164257\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8ba868a2-72fc-42d3-be5e-ef056f74b2f0>\",\"WARC-Concurrent-To\":\"<urn:uuid:362e6507-c828-4c06-81b9-029c48769f40>\",\"WARC-IP-Address\":\"104.18.43.226\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/326646/markov-chain-transition-probabilities-for-3-variables/326649\",\"WARC-Payload-Digest\":\"sha1:I77PQAF26PPBE6B7HEJTUTWJRUJCXAJM\",\"WARC-Block-Digest\":\"sha1:HYAUKLNREXF6AVNHTHNSEWNBT5OTEN3L\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100258.29_warc_CC-MAIN-20231130225634-20231201015634-00783.warc.gz\"}"}