<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mehmet ONAL on Medium]]></title>
        <description><![CDATA[Stories by Mehmet ONAL on Medium]]></description>
        <link>https://medium.com/@mhmt_onal?source=rss-41acefd504e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*c9WNBveJzYrUNtWp</url>
            <title>Stories by Mehmet ONAL on Medium</title>
            <link>https://medium.com/@mhmt_onal?source=rss-41acefd504e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:51:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhmt_onal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hidden Markov Models With Real World Examples]]></title>
            <link>https://medium.com/@mhmt_onal/hidden-markov-models-with-real-world-examples-2d1c8ea143b1?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d1c8ea143b1</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[hidden-markov-models]]></category>
            <category><![CDATA[markov-decision-process]]></category>
            <category><![CDATA[markov-chains]]></category>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 23:53:00 GMT</pubDate>
            <atom:updated>2026-10-24T23:53:00.509Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi friends! In this article, I will try to explain Hidden Markov Models (HMMs) with some real-world examples.</p><p>In my previous article, I explained Markov Chains using a League of Legends role selection example.</p><p>As you may remember, the most important thing in a Markov Chain is the <strong>current state</strong>. We don’t need the entire history to predict the next state. We only need to know the current state.</p><p>But what if we don’t know the current state?</p><p>In a regular Markov Chain, if we don’t know the current state, we can start with a probability distribution over possible states. Then, using transition probabilities, we can calculate how these probabilities change over time.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><p>However, Hidden Markov Models introduce something different.</p><blockquote><strong>What if we cannot directly observe the actual state, but we can observe something related to it?</strong></blockquote><p>This is where Hidden Markov Models come into play.</p><p>Let’s remember our League of Legends example. Imagine your friend want to play LoL every day. Yesterday, your friend played Jungle. You want to predict which role he/she will choose today. In a Markov Chain, we know the current state and we use transition probabilites to predict the next state. But let’s change our example a little bit.</p><p>Imagine you want to know your friend’s mood while playing LoL</p><p>There are three possible moods:</p><ul><li>Focused</li><li>Tired</li><li>Frustrated</li></ul><p>The problem is that you cannot directly observe your friend’s mood. You cannot look inside their mind, right. However, you can observe their performance in the game.</p><p>For example :</p><ul><li>If your friend plays very well, they might be focused.</li><li>If your friend makes many mistakes, they might be tired.</li><li>If your friend plays aggressively and makes risky decisions, they might be frustrated.</li></ul><p>Of course, these observations are not always correct. A focused player can also make mistakes, and a tired player can still play very well.</p><ol><li><strong>Hidden States:</strong> The actual states that we cannot directly observe. In our example, these are Focused, Tired, and Frustrated.</li><li><strong>Observations:</strong> The things we can see. In our example, these are Good Performance, Average Performance, and Bad Performance.</li></ol><p>The main idea is simple: We use what we can observe to estimate what we cannot directly see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*D--VTtqZSnxLhNceWNzvNA.png" /></figure><h3>How Does a Hidden Markov Model Work?</h3><p>Now we know the difference between Hidden States and Observations. But how can we use them to make predictions?</p><p>For this, we need three important components:</p><ol><li>Transition Probabilities</li><li>Emission Probabilities</li><li>Initial Probabilities</li></ol><p>Let’s continue with our League of Legends example.</p><h3>1. Transition Probabilities</h3><p>Imagine your friend is playing League of Legends every day. As we discussed before, your friend can be in three different hidden states: <strong>Focused, Tired, or Frustrated</strong>. Their mood can change from one day to another. For example, if your friend is Focused today, they might still be Focused tomorrow. But they might also become Tired or Frustrated. We can represent these possibilities using a transition probability table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*WKim_V1i7uBoRZweBd1qew.png" /></figure><p>Let’s look at the first row.</p><p>If your friend is Focused today:</p><ul><li>There is a 70% chance they will be Focused tomorrow.</li><li>There is a 20% chance they will be Tired tomorrow.</li><li>There is a 10% chance they will be Frustrated tomorrow.</li></ul><p>Notice that the probabilities in each row add up to 1.</p><h3>2. Emission Probabilities</h3><p>Here comes the interesting part!</p><p>We cannot directly observe our friend’s mood. However, we can observe their performance. Let’s say there are three possible observations:</p><ul><li>Good Performance</li><li>Average Performance</li><li>Bad Performance</li></ul><p>Different hidden states can produce different observations. For example, a Focused player will probably play well. However, being Focused does not guarantee Good Performance. Let’s create another probability table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*JY3aiUheIh1uUwXLaAvXkw.png" /></figure><p>Let’s look at the Focused row.</p><p>If your friend is Focused:</p><ul><li>There is an 80% chance of Good Performance.</li><li>There is a 15% chance of Average Performance.</li><li>There is a 5% chance of Bad Performance.</li></ul><p>But be careful!</p><p><strong><em>P(Good Performance | Focused)</em> is not the same as<em> P(Focused | Good Performance)</em>.</strong></p><p>→The first one tells us the probability of Good Performance when the player is Focused. →The second one asks: If we observe Good Performance, how likely is it that the player is Focused?</p><p>These are two different questions!</p><p>Emission probabilities tell us how likely an observation is, given a hidden state.</p><h3>3. Initial Probabilities</h3><p>We have one more question. What is our friend’s mood before we start observing their performance? Since we don’t know the actual hidden state, we need an initial probability distribution.</p><p>Let’s assume:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*KFEJJ_1mzbd9c_ULupl3kQ.png" /></figure><p>This means that before observing any game, we believe there is a 50% chance our friend is Focused, a 30% chance they are Tired, and a 20% chance they are Frustrated.</p><p>We call this the <strong>Initial State Distribution</strong>, usually represented by the Greek letter π (pi).</p><p>Now we have everything we need to build a basic Hidden Markov Model!</p><ul><li><strong>Transition Probabilities (A):</strong> How hidden states change over time.</li><li><strong>Emission Probabilities (B):</strong> How hidden states produce observations.</li><li><strong>Initial Probabilities (π):</strong> How likely each hidden state is at the beginning.</li></ul><p>But we still have an important question.</p><p><strong>If we only observe our friend’s performance over several days, can we calculate how likely those observations are?</strong></p><p>Yes! And this brings us to our first HMM algorithm: the <strong>Forward Algorithm</strong>.</p><h3>Solving a Hidden Markov Model: The Forward Algorithm</h3><h3>What Is the Forward Algorithm?</h3><p>In the previous sections, we learned about hidden states, observations, transition probabilities, emission probabilities, and initial probabilities.</p><p>Now, let’s see how we can use them to solve a real problem.</p><p>The <strong>Forward Algorithm</strong> is an algorithm used in Hidden Markov Models to calculate the probability of observing a specific sequence of events. Remember that in Hidden Markov Models, we cannot directly observe the hidden states. We can only observe the events produced by these states.</p><p>For example, imagine that we observe a League of Legends player’s performance for three days.</p><ul><li>Day 1: Good Performance</li><li>Day 2: Bad Performance</li><li>Day 3: Good Performance</li></ul><p>We don’t know the player’s actual mood during these days. They might be Focused, Tired, or Frustrated.</p><p>But we have a question:</p><p><strong>What is the probability of observing Good → Bad → Good according to our Hidden Markov Model?</strong></p><p>To answer this question, we use the Forward Algorithm.</p><p>The main idea is simple. Instead of trying to guess one hidden state sequence, the Forward Algorithm considers <strong>all possible hidden state paths</strong> that could produce our observations. It calculates the probability of each observation step by step, using the initial, transition, and emission probabilities. At each step, we consider all possible previous hidden states, multiply their probabilities by the corresponding transition probabilities, add these contributions together, and then multiply by the emission probability of the current observation.</p><p>We repeat this process until the last observation.</p><p>Finally, we add the probabilities of all possible hidden states on the last day to get the probability of the entire observation sequence. This process is called the <strong>Forward Algorithm</strong>.</p><h3>Let’s Solve an Example!</h3><p>Let’s continue with our League of Legends example.</p><p>Imagine your friend plays League of Legends every day. You want to analyze their performance over three days using a Hidden Markov Model.</p><p>We have three possible hidden states:</p><ul><li><strong>Focused (F)</strong></li><li><strong>Tired (T)</strong></li><li><strong>Frustrated (R)</strong></li></ul><p>And three possible observations:</p><ul><li><strong>Good Performance (G)</strong></li><li><strong>Average Performance (A)</strong></li><li><strong>Bad Performance (B)</strong></li></ul><p>Our model has the following probabilities.</p><h3>Initial Probabilities (π)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*tgP2Z-9YFua0PDTLiIvOsg.png" /></figure><h3>Transition Probabilities (A)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*pHlqGJajabk58U2vI5FZJA.png" /></figure><h3>Emission Probabilities (B)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*M1l42NOmn1ylc53FqU_Rpg.png" /></figure><h3>Our Question</h3><p>We observe our friend’s performance for three days:</p><p><strong>Day 1: Good → Day 2: Bad → Day 3: Good</strong></p><p>Using the Forward Algorithm, calculate the probability of observing this exact sequence.</p><p><strong>P(Good, Bad, Good) = ?</strong></p><p>Before we start calculating, we need to learn one symbol.</p><h3>What Is Alpha (α)?</h3><p>In the Forward Algorithm, we use a Greek letter called <strong>alpha (α)</strong>.</p><p>Alpha represents the probability of observing all the events up to a specific day <strong>and</strong> being in a specific hidden state on that day.</p><p>For example:</p><p><strong>α₁(F)</strong> means the probability that:</p><ul><li>Day 1 has Good Performance.</li><li>The hidden state on Day 1 is Focused.</li></ul><p>Similarly, <strong>α₂(T)</strong> means the probability that:</p><ul><li>Day 1 has Good Performance.</li><li>Day 2 has Bad Performance.</li><li>The hidden state on Day 2 is Tired.</li></ul><p>Notice that α₂(T) includes the observations from both days, not only Day 2.</p><p>Now we are ready to start!</p><h3>Step 1: Day 1 — Good Performance</h3><p>On the first day, we observe Good Performance. Since we don’t know our friend’s hidden state, we calculate a probability for each possible state. For the first day, the calculation is simple:</p><p><strong>Alpha = Initial Probability × Emission Probability</strong></p><h3>Focused</h3><blockquote>Initial probability of Focused = 0.5</blockquote><blockquote>Probability of Good Performance when Focused = 0.8</blockquote><blockquote><strong>α₁(F) = 0.5 × 0.8 = 0.4</strong></blockquote><h3>Tired</h3><blockquote>Initial probability of Tired = 0.3</blockquote><blockquote>Probability of Good Performance when Tired = 0.2</blockquote><blockquote><strong>α₁(T) = 0.3 × 0.2 = 0.06</strong></blockquote><h3>Frustrated</h3><blockquote>Initial probability of Frustrated = 0.2</blockquote><blockquote>Probability of Good Performance when Frustrated = 0.1</blockquote><blockquote><strong>α₁(R) = 0.2 × 0.1 = 0.02</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*RnLKS3mO7bk1uxz0Aaa4yA.png" /></figure><p>If we add these values:</p><p><strong>P(Good) = 0.40 + 0.06 + 0.02 = 0.48</strong></p><p>This means that the probability of observing Good Performance on the first day is 48%. But our observation sequence has three days, so let’s continue!</p><h3>Step 2: Day 2 — Bad Performance</h3><p>On the second day, we observe Bad Performance. Now things become a little more interesting.</p><p>→ Our friend might have been Focused on Day 1 and become Tired on Day 2</p><p>→ Or they might have been Frustrated on Day 1 and become Focused on Day 2.</p><p>We need to consider all these possibilities.</p><p>For each hidden state on Day 2, we:</p><ol><li>Multiply each previous alpha value by its transition probability to the current state.</li><li>Add these values together.</li><li>Multiply the result by the emission probability of Bad Performance.</li></ol><p>Let’s calculate!</p><h3>Focused</h3><p>There are three possible ways to reach Focused on Day 2:</p><ul><li>Focused → Focused: 0.40 × 0.7 = 0.28</li><li>Tired → Focused: 0.06 × 0.3 = 0.018</li><li>Frustrated → Focused: 0.02 × 0.2 = 0.004</li></ul><p>First, we add these values:</p><p>0.28 + 0.018 + 0.004 = 0.302</p><p>Then, we multiply by the probability of Bad Performance when Focused, which is 0.05.</p><p><strong>α₂(F) = 0.302 × 0.05 = 0.0151</strong></p><h3>Tired</h3><p>There are three possible ways to reach Tired on Day 2:</p><ul><li>Focused → Tired: 0.40 × 0.2 = 0.08</li><li>Tired → Tired: 0.06 × 0.5 = 0.03</li><li>Frustrated → Tired: 0.02 × 0.3 = 0.006</li></ul><p>We add these values:</p><p>0.08 + 0.03 + 0.006 = 0.116</p><p>Then, we multiply by the probability of Bad Performance when Tired, which is 0.3.</p><p><strong>α₂(T) = 0.116 × 0.3 = 0.0348</strong></p><h3>Frustrated</h3><p>There are three possible ways to reach Frustrated on Day 2:</p><ul><li>Focused → Frustrated: 0.40 × 0.1 = 0.04</li><li>Tired → Frustrated: 0.06 × 0.2 = 0.012</li><li>Frustrated → Frustrated: 0.02 × 0.5 = 0.01</li></ul><p>We add these values:</p><p>0.04 + 0.012 + 0.01 = 0.062</p><p>Then, we multiply by the probability of Bad Performance when Frustrated, which is 0.6.</p><p><strong>α₂(R) = 0.062 × 0.6 = 0.0372</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*DnXqjiLbXqzGPNI0K0VGIg.png" /></figure><p>Notice that we used the alpha values from Day 1 instead of the initial probabilities.</p><p>This is how the Forward Algorithm works: <strong>each step uses the results of the previous step.</strong></p><h3>Step 3: Day 3 — Good Performance</h3><p>On the third day, our friend performs well again. We repeat the same process using the alpha values from Day 2.</p><h3>Focused</h3><p>First, we consider all possible transitions to Focused:</p><ul><li>Focused → Focused: 0.0151 × 0.7 = 0.01057</li><li>Tired → Focused: 0.0348 × 0.3 = 0.01044</li><li>Frustrated → Focused: 0.0372 × 0.2 = 0.00744</li></ul><p>We add them:</p><p>0.01057 + 0.01044 + 0.00744 = 0.02845</p><p>Then, we multiply by the emission probability of Good Performance when Focused (0.8).</p><p><strong>α₃(F) = 0.02845 × 0.8 = 0.02276</strong></p><h3>Tired</h3><p>Possible transitions to Tired:</p><ul><li>Focused → Tired: 0.0151 × 0.2 = 0.00302</li><li>Tired → Tired: 0.0348 × 0.5 = 0.0174</li><li>Frustrated → Tired: 0.0372 × 0.3 = 0.01116</li></ul><p>We add them:</p><p>0.00302 + 0.0174 + 0.01116 = 0.03158</p><p>Then, we multiply by the emission probability of Good Performance when Tired (0.2).</p><p><strong>α₃(T) = 0.03158 × 0.2 = 0.006316</strong></p><h3>Frustrated</h3><p>Possible transitions to Frustrated:</p><ul><li>Focused → Frustrated: 0.0151 × 0.1 = 0.00151</li><li>Tired → Frustrated: 0.0348 × 0.2 = 0.00696</li><li>Frustrated → Frustrated: 0.0372 × 0.5 = 0.0186</li></ul><p>We add them:</p><p>0.00151 + 0.00696 + 0.0186 = 0.02707</p><p>Then, we multiply by the emission probability of Good Performance when Frustrated (0.1).</p><p><strong>α₃(R) = 0.02707 × 0.1 = 0.002707</strong></p><p>Our final alpha values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*l2_eHll2P44yx_C-aQgh2g.png" /></figure><h3>Final Result</h3><p>We have reached the last day!</p><p>Now, we add all the alpha values from Day 3 to calculate the probability of observing the entire sequence.</p><p><strong>P(Good, Bad, Good) = α₃(F) + α₃(T) + α₃(R)</strong></p><p><strong>P(Good, Bad, Good) = 0.022760 + 0.006316 + 0.002707</strong></p><p><strong>P(Good, Bad, Good) = 0.031783</strong></p><p>Our final answer is approximately <strong>3.18%</strong>.</p><p>According to our Hidden Markov Model, the probability of observing Good → Bad → Good over three days is approximately 3.18%.</p><p>We calculated this probability without knowing our friend’s actual mood on any of the three days.</p><p>The important point is that we did not select just one possible hidden state sequence. We considered all possible paths through the Forward Algorithm.</p><h3>What’s Next? The Viterbi Algorithm</h3><p>We now know the probability of observing Good → Bad → Good. But we still have another interesting question.</p><p><strong>What was the most likely sequence of hidden moods behind these performances?</strong></p><p>Was our friend Focused → Tired → Focused?</p><p>Or maybe Focused → Frustrated → Focused?</p><p>The Forward Algorithm calculates the probability of the observations by considering all possible hidden state paths. However, it does not directly identify the single most likely hidden state sequence. For that, we need another algorithm called the <strong>Viterbi Algorithm</strong>. In the next section, we will solve the same example using Viterbi and find the most likely hidden state sequence behind our friend’s performance.</p><h3>Solving a Hidden Markov Model: The Viterbi Algorithm</h3><h3>What Is the Viterbi Algorithm?</h3><p>In the previous section, we learned how to calculate the probability of an observation sequence using the Forward Algorithm.</p><p>We observed our friend’s League of Legends performance for three days:</p><ul><li>Day 1: Good Performance</li><li>Day 2: Bad Performance</li><li>Day 3: Good Performance</li></ul><p>Using the Forward Algorithm, we calculated that the probability of observing this sequence was approximately <strong>3.18%</strong>. But we still have an interesting question.</p><p><strong>What were our friend’s most likely hidden moods during these three days?</strong></p><p>We know their performance, but we don’t know if they were Focused, Tired, or Frustrated. This is where the <strong>Viterbi Algorithm</strong> comes into play!</p><p>The Viterbi Algorithm helps us find the single most likely sequence of hidden states that could have produced our observations. The main idea is similar to the Forward Algorithm, but there is one important difference. In the Forward Algorithm, we consider all possible previous states and <strong>add their probability contributions together</strong>.In the Viterbi Algorithm, instead of adding them, we <strong>select the maximum probability</strong>.</p><p>Why?</p><p>Because we are no longer trying to calculate the total probability of our observations. We want to find the most likely hidden state path. There is one more important thing. While calculating the maximum probabilities, we also remember which previous hidden state gave us the best result. At the end, we use these saved states to reconstruct the most likely hidden state sequence.</p><p>This process is called <strong>Backtracking</strong>.</p><p>Let’s solve our example!</p><h3>Our Example: League of Legends Player Performance</h3><p>We will use exactly the same probabilities from our Forward Algorithm example.</p><h3>Hidden States</h3><ul><li><strong>Focused (F)</strong></li><li><strong>Tired (T)</strong></li><li><strong>Frustrated (R)</strong></li></ul><h3>Observations</h3><ul><li><strong>Good Performance (G)</strong></li><li><strong>Average Performance (A)</strong></li><li><strong>Bad Performance (B)</strong></li></ul><h3>1. Initial Probabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*AIXZR-DxuwfvGAs8vNlggg.png" /></figure><h3>2. Transition Probabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*cVFnj8JXur_Xa-Cx9ztDBw.png" /></figure><h3>3. Emission Probabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*z8OldSCVx8L3Wkn_Ktzesw.png" /></figure><p>These probabilities are hypothetical and created for our example.</p><h3>Our Question</h3><p>We observe our friend’s performance for three days:</p><p><strong>Day 1: Good → Day 2: Bad → Day 3: Good</strong></p><p>Using the Viterbi Algorithm, find the most likely hidden state sequence that produced these observations.</p><p>For example, could it be:</p><p>Focused → Tired → Focused?</p><p>Or maybe:</p><p>Focused → Frustrated → Focused?</p><p>Let’s find out!</p><h3>Before We Start: What Is Delta (δ)?</h3><p>In the Forward Algorithm, we used a Greek letter called alpha (α). In the Viterbi Algorithm, we use another Greek letter called <strong>delta (δ)</strong>. Delta represents the probability of the <strong>most likely hidden state path</strong> that ends in a specific state and produces all observations up to that day.</p><p>For example:</p><p><strong>δ₁(F)</strong> represents the probability of starting in Focused and observing Good Performance on Day 1.</p><p><strong>δ₂(T)</strong> represents the probability of the most likely hidden state path that:</p><ul><li>Produces Good Performance on Day 1.</li><li>Produces Bad Performance on Day 2.</li><li>Ends in Tired on Day 2.</li></ul><p>The difference is that delta only keeps the probability of the best path, while alpha considers all possible paths. We will also save the best previous state for each calculation.</p><p>Now, let’s start!</p><h3>Step 1: Day 1 — Good Performance</h3><p>On the first day, we observe Good Performance. Just like the Forward Algorithm, we multiply the initial probabilities by the emission probabilities.</p><p><strong>Delta = Initial Probability × Emission Probability</strong></p><h3>Focused</h3><p>Initial probability of Focused = 0.5</p><p>Probability of Good Performance when Focused = 0.8</p><p><strong>δ₁(F) = 0.5 × 0.8 = 0.4</strong></p><h3>Tired</h3><p>Initial probability of Tired = 0.3</p><p>Probability of Good Performance when Tired = 0.2</p><p><strong>δ₁(T) = 0.3 × 0.2 = 0.06</strong></p><h3>Frustrated</h3><p>Initial probability of Frustrated = 0.2</p><p>Probability of Good Performance when Frustrated = 0.1</p><p><strong>δ₁(R) = 0.2 × 0.1 = 0.02</strong></p><p>Our results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*G0ZY11pPsOW_8kqMuhQIMA.png" /></figure><p>Notice that these values are exactly the same as the first day of the Forward Algorithm. This is because we haven’t made any transitions yet.</p><h3>Step 2: Day 2 — Bad Performance</h3><p>On the second day, we observe Bad Performance. Now we need to consider the possible transitions from Day 1 to Day 2. But remember our important rule:</p><p><strong>Instead of adding the probabilities, we select the maximum probability.</strong></p><p>For every possible hidden state on Day 2, we:</p><ol><li><strong>Multiply each previous delta value by its transition probability to the current state.</strong></li><li><strong>Select the maximum result.</strong></li><li><strong>Multiply that maximum by the emission probability of Bad Performance.</strong></li><li><strong>Save the previous state that produced the maximum.</strong></li></ol><p>Let’s calculate!</p><h3>Focused</h3><p>There are three possible ways to reach Focused on Day 2:</p><ul><li>Focused → Focused: 0.40 × 0.7 = 0.28</li><li>Tired → Focused: 0.06 × 0.3 = 0.018</li><li>Frustrated → Focused: 0.02 × 0.2 = 0.004</li></ul><p>We select the maximum:</p><p><strong>max(0.28, 0.018, 0.004) = 0.28</strong></p><p>Then, we multiply by the emission probability of Bad Performance when Focused (0.05).</p><p><strong>δ₂(F) = 0.28 × 0.05 = 0.014</strong></p><p>The maximum came from Focused.</p><p>So we save:</p><p><strong>Best Previous State = Focused</strong></p><h3>Tired</h3><p>Possible transitions to Tired:</p><ul><li>Focused → Tired: 0.40 × 0.2 = 0.08</li><li>Tired → Tired: 0.06 × 0.5 = 0.03</li><li>Frustrated → Tired: 0.02 × 0.3 = 0.006</li></ul><p>We select the maximum:</p><p><strong>max(0.08, 0.03, 0.006) = 0.08</strong></p><p>Then, we multiply by the emission probability of Bad Performance when Tired (0.3).</p><p><strong>δ₂(T) = 0.08 × 0.3 = 0.024</strong></p><p>The maximum came from Focused.</p><p><strong>Best Previous State = Focused</strong></p><h3>Frustrated</h3><p>Possible transitions to Frustrated:</p><ul><li>Focused → Frustrated: 0.40 × 0.1 = 0.04</li><li>Tired → Frustrated: 0.06 × 0.2 = 0.012</li><li>Frustrated → Frustrated: 0.02 × 0.5 = 0.01</li></ul><p>We select the maximum:</p><p><strong>max(0.04, 0.012, 0.01) = 0.04</strong></p><p>Then, we multiply by the emission probability of Bad Performance when Frustrated (0.6).</p><p><strong>δ₂(R) = 0.04 × 0.6 = 0.024</strong></p><p>The maximum came from Focused.</p><p><strong>Best Previous State = Focused</strong></p><p>Our Day 2 results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*tfXZLQUnI0Uk8d0yGEuIVg.png" /></figure><p>Notice something interesting!</p><p>Even though we observed Bad Performance, all three best paths started from Focused on Day 1. We are not trying to guess the mood based only on one day’s performance.</p><p>We are considering both transition and emission probabilities.</p><h3>Step 3: Day 3 — Good Performance</h3><p>On the third day, our friend performs well again. We repeat the same process, but this time we use the delta values from Day 2.</p><h3>Focused</h3><p>Possible transitions to Focused:</p><ul><li>Focused → Focused: 0.014 × 0.7 = 0.0098</li><li>Tired → Focused: 0.024 × 0.3 = 0.0072</li><li>Frustrated → Focused: 0.024 × 0.2 = 0.0048</li></ul><p>We select the maximum:</p><p><strong>max(0.0098, 0.0072, 0.0048) = 0.0098</strong></p><p>Then, we multiply by the emission probability of Good Performance when Focused (0.8).</p><p><strong>δ₃(F) = 0.0098 × 0.8 = 0.00784</strong></p><p><strong>Best Previous State = Focused</strong></p><h3>Tired</h3><p>Possible transitions to Tired:</p><ul><li>Focused → Tired: 0.014 × 0.2 = 0.0028</li><li>Tired → Tired: 0.024 × 0.5 = 0.012</li><li>Frustrated → Tired: 0.024 × 0.3 = 0.0072</li></ul><p>We select the maximum:</p><p><strong>max(0.0028, 0.012, 0.0072) = 0.012</strong></p><p>Then, we multiply by the emission probability of Good Performance when Tired (0.2).</p><p><strong>δ₃(T) = 0.012 × 0.2 = 0.0024</strong></p><p><strong>Best Previous State = Tired</strong></p><h3>Frustrated</h3><p>Possible transitions to Frustrated:</p><ul><li>Focused → Frustrated: 0.014 × 0.1 = 0.0014</li><li>Tired → Frustrated: 0.024 × 0.2 = 0.0048</li><li>Frustrated → Frustrated: 0.024 × 0.5 = 0.012</li></ul><p>We select the maximum:</p><p><strong>max(0.0014, 0.0048, 0.012) = 0.012</strong></p><p>Then, we multiply by the emission probability of Good Performance when Frustrated (0.1).</p><p><strong>δ₃(R) = 0.012 × 0.1 = 0.0012</strong></p><p><strong>Best Previous State = Frustrated</strong></p><p>Our Day 3 results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*PYk4aAquodyOcfCyveKe-A.png" /></figure><h3>Step 4: Finding the Most Likely Hidden State Sequence</h3><p>Now we have reached the last day.</p><p>Our final delta values are:</p><ul><li>Focused: 0.00784</li><li>Tired: 0.00240</li><li>Frustrated: 0.00120</li></ul><p>We select the maximum:</p><p><strong>max(0.00784, 0.00240, 0.00120) = 0.00784</strong></p><p>The most likely final hidden state is <strong>Focused</strong>. But we are not finished yet! We know the most likely state on Day 3, but we still need to find the most likely states on Day 2 and Day 1.</p><p>For this, we use a process called Backtracking.</p><h3>What Is Backtracking?</h3><p><strong>Important Note:</strong></p><p>In the Viterbi Algorithm, we do not simply choose the state with the highest Delta value on each day. Instead, for each possible state, we calculate and save the most likely path that reaches that state. We keep all these results until the final day. Only at the final day do we select the state with the highest Delta value. Then, we follow the saved previous states backward to reconstruct the most likely hidden state sequence.</p><p>This process is called <strong>Backtracking</strong>.</p><p>Remember that during our calculations, we saved the best previous state for each possible hidden state. Now, we follow these saved states backward, starting from our best final state.</p><p>Let’s do it step by step.</p><p><strong>Day 3: Focused</strong></p><p>Our maximum final delta value belongs to Focused. We look at the best previous state we saved for Day 3 Focused.</p><ul><li>It was Focused.</li></ul><p><strong>Day 2: Focused</strong></p><p>Now we look at the best previous state for Day 2 Focused.</p><ul><li>It was also Focused.</li></ul><p><strong>Day 1: Focused</strong></p><p>We have reached the beginning of our sequence.</p><p>Our most likely hidden state sequence is:</p><p><strong>Focused → Focused → Focused</strong></p><p>Even though our friend performed badly on Day 2, the most likely hidden state for that day is still Focused when we consider the entire sequence.</p><p>Why?</p><p>Because our model gives a relatively high probability of staying Focused from one day to another. And even a Focused player can have Bad Performance!</p><h3>Final Result</h3><p>Let’s check the probability of our most likely hidden state sequence together with the observed performances.</p><p>Our hidden state sequence:</p><p><strong>Focused → Focused → Focused</strong></p><p>Our observation sequence:</p><p><strong>Good → Bad → Good</strong></p><p>We multiply the initial probability, the emission probabilities, and the transition probabilities along this path.</p><p><strong>Probability = 0.5 × 0.8 × 0.7 × 0.05 × 0.7 × 0.8</strong></p><p><strong>Probability = 0.00784</strong></p><p>This is the joint probability of this hidden state path and our observations. It does not mean that our friend was definitely Focused for all three days. It means that, according to our Hidden Markov Model, this is the single most likely hidden state sequence that could have produced our observations.</p><h3>Forward Algorithm vs. Viterbi Algorithm</h3><p>We have now solved the same Hidden Markov Model using two different algorithms.</p><p>Let’s compare their results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*yaY5sxzNUwX8R3j2WFB34g.png" /></figure><p>There is one final detail worth understanding.</p><p>Our Forward Algorithm result was <strong>0.031783</strong>, but our Viterbi path probability was only <strong>0.00784</strong>.</p><p>Why are these numbers different?</p><p>Because the Forward Algorithm adds the probabilities of all possible hidden state paths that could produce the observation sequence. The Viterbi Algorithm only finds the path with the highest joint probability. In our example, there are 3 possible hidden states for each of the 3 days. That means there are:</p><p><strong>3 × 3 × 3 = 27 possible hidden state sequences.</strong></p><p>Forward considers all 27 paths, while Viterbi finds the most likely one. This is the key difference between these two algorithms.</p><h3>Conclusion</h3><p>We have learned how Hidden Markov Models can help us understand situations where we cannot directly observe the actual states. Using our League of Legends example, we saw how a player’s hidden mood might affect their performance.</p><p>We also learned two important algorithms:</p><ul><li><strong>Forward Algorithm:</strong> Calculates the probability of an observation sequence.</li><li><strong>Viterbi Algorithm:</strong> Finds the most likely hidden state sequence behind the observations.</li></ul><p>Both algorithms use initial, transition, and emission probabilities, but they answer different questions. And the best part is that these algorithms are not limited to video games! Hidden Markov Models have been used in speech recognition, natural language processing, biological sequence analysis, and many other areas. I hope this example helped you understand how Forward and Viterbi work.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d1c8ea143b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Markov Chain Practice Questions]]></title>
            <link>https://medium.com/@mhmt_onal/markov-chain-practice-questions-6fc0f5651d23?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fc0f5651d23</guid>
            <category><![CDATA[markov-models]]></category>
            <category><![CDATA[markov-chains]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 21:20:58 GMT</pubDate>
            <atom:updated>2026-10-18T21:20:58.343Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bonus Challenge 1.A: Will Our Game Server Be Offline 40% of the Time?</h3><p>Imagine an online game server that can be in one of three states each day: <strong>Normal (N), Laggy (L), or Offline (O)</strong>. The server’s status changes according to the following transition probability matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*LmftQqnUaS7kHouy-3zXyw.png" /><figcaption>Transition Matrix</figcaption></figure><p>One of our friends looks at the transition matrix and makes the following claim:</p><blockquote><em>“The probability of staying Offline is 0.40. Therefore, regardless of the server’s current state, it will eventually be Offline 40% of the time.”</em></blockquote><p><strong>Do you agree with this statement?</strong> Without calculating the stationary distribution, explain whether this conclusion is reasonable. Use the transition probabilities to support your reasoning.</p><p><strong>Hint:</strong> Is the probability of remaining in a particular state after one transition the same as the long-term probability of being in that state?</p><h4>ANSWER:</h4><blockquote>Our friend’s claim is only partially correct. The probability of staying Offline is 40%, given that the server is currently Offline. <strong>BUT</strong> we cannot conclude that the server will be Offline 40% of the time in the long run.</blockquote><blockquote>These probabilities are <strong>transition probabilities</strong>, not stationary probabilities. As we know from Markov Chains, transition probabilities describe the chances of moving between states in one step. However, they also determine the long-term behavior of the system when applied repeatedly.</blockquote><blockquote>If we look at our transition matrix, the probabilities of moving from Normal and Laggy to Offline are only 0.05 and 0.15, respectively. Meanwhile, the probability of leaving the Offline state is 0.60. This suggests that the long-term probability of being Offline should be much lower than 40%.</blockquote><blockquote>We can calculate the stationary distribution directly from the transition matrix without knowing the initial probability distribution in this example. However, <strong>we cannot determine the stationary probability simply by looking at a single transition probability</strong>.</blockquote><blockquote>Therefore, I don’t agree with our friend’s conclusion. <strong>A 40% probability of staying Offline for one more day does not mean the server will be Offline 40% of the time in the long run.</strong></blockquote><h3>1.B-Two-Step Transition Probability</h3><p>Suppose our game server is <strong>Normal on Monday</strong>. What is the probability that it will be <strong>Offline on Wedn</strong>.<strong>esday</strong>?</p><p>Assume the server changes its state once per day according to our transition matrix</p><h4>Answer</h4><blockquote>Since Monday to Wednesday involves two transitions, we need to calculate the two-step transition probability from Normal to Offline.</blockquote><blockquote>There are three possible paths: Normal → Normal → Offline, Normal → Laggy → Offline, and Normal → Offline → Offline. We multiply the transition probabilities along each path and then add the results.</blockquote><blockquote><strong>P(N → O in two steps) = 0.0825 = 8.25%</strong></blockquote><blockquote>Therefore, if our server is Normal on Monday, there is an <strong>8.25% probability that it will be Offline on Wednesday</strong>.</blockquote><blockquote>Remember, we multiply the probabilities along each path and add the probabilities of different paths!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*rnCXe8tUPotdZm4xaPX5vw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-GrSADjhoyq9IGs948Y6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*Gj4UEmF1_kLV6tdYSM3jPw.png" /></figure><h3>Bonus Challenge 2 : Will We Ever Finish Our Coding Project?</h3><p>Imagine a computer science student working on a programming project. During each study session, the project can be in one of four states: <strong>Coding ©, Debugging (D), Testing (T), or Submitted (S)</strong>. Depending on the progress made, the project may move between these states according to the following transition probability matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*CTdQdKFJbAwD_4Ek2pkvLQ.png" /></figure><p>Once the project is submitted, our student can finally relax (at least until the next assignment!). We assume that the project cannot return to Coding, Debugging, or Testing after submission.</p><h4><strong>Question 2.A — Absorbing States and Long-Term Behavior</strong></h4><p>Is Submitted an absorbing state? Explain what this means for the project’s long-term behavior. If we repeatedly apply our transition matrix, what stationary distribution should we eventually approach, regardless of the project’s initial state?</p><h4><strong>Question 2.B — Two-Step Transition Probability</strong></h4><p>Suppose our student starts in the <strong>Coding</strong> state with 100% probability.</p><p>What is the probability that the project will be <strong>Submitted by the end of two study sessions</strong>? Remember that the project may be submitted during the first session as well.</p><p>Show your calculations using the transition matrix and explain which possible paths contribute to the final probability.</p><h4><strong>Question 2.C — Convergence</strong></h4><p>Suppose we have two different initial probability distributions:</p><p><strong>Scenario 1:</strong> The project starts in Coding with 100% probability.</p><p><strong>Scenario 2:</strong> The project starts in Testing with 100% probability.</p><p>If we repeatedly multiply both initial distributions by the same transition matrix, will they eventually converge to the same probability distribution?Explain your reasoning and describe the role of the absorbing state in this process.</p><h3>Solutions 2</h3><h4>Answer 2.A:</h4><p>The student can <strong>Coding ©, Debugging (D), Testing (T), or Submitted (S) </strong>aswell. But as stated in the question, there is an Absorbing State. If the project is submitted, sthe student cannot go back to the previous states. During the first few transitions, represented by P¹, P², and P³ student can write code then write more code then debug the code and test the code. But eventually the project will eventually reach Submitted with probability 1. Once the project is submitted, the student cannot return to the previous states. And eventually stationary probability will be like : <em>π </em>* = [0,0,0,1]. Since submitted stat can be reached from every other state and cannot be left the probability of being in Submitted aproaches 1 as time goes on.</p><h4>Answer 2.B:</h4><p><strong>Step 1 — Define Our Initial Probability Distribution</strong></p><p>Since our student starts in the Coding state with 100% probability, our initial probability distribution is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/1*pEoc6fpci-nYK6gtJxM2Mw.png" /></figure><p>Recall our transition matrix, where the states are ordered as Coding ©, Debugging (D), Testing (T), and Submitted (S):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*XKC_xzhR-3ddZ3zi4PjNxQ.png" /></figure><p><strong>Step 2 — Identify All Possible Paths</strong></p><p>We want to find the probability of being in the Submitted state after two transitions. As we learned in Part 2, we can calculate this using:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/81/1*T9gC7Oan46ZUOPCZUNlKWg.png" /></figure><p>However, instead of multiplying the entire matrix, let’s identify all possible paths from Coding to Submitted in two transitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*gokU3TNMuYuodU4jzrbaOQ.png" /></figure><p><strong>Step 3 — Calculate the Total Probability</strong></p><p>We multiply the probabilities along each path and then add the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*a87QkA6pI-xlda6b3QT91Q.png" /></figure><p><strong>Step 4 — Verify Using Matrix Multiplication</strong></p><p>We can also verify our answer by multiplying the initial distribution by the transition matrix twice:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*A2lpgPay6kBlLEDAzox5Kg.png" /></figure><p>Now, multiply once more:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*ddbeTmFcVHnZ4Z7IBOjeqA.png" /></figure><h4>Answer 2.C</h4><p>Yes! Both scenarios will eventually <strong>converge to the same probability distribution</strong>, even though they start in different states.</p><p>Let’s examine our two initial probability distributions.</p><p><strong>Scenario 1 — Starting in Coding:</strong></p><p>π₀ = [1, 0, 0, 0]</p><p><strong>Scenario 2 — Starting in Testing:</strong></p><p>π₀ = [0, 0, 1, 0]</p><p>As we learned in Part 2, we can calculate the probability distribution after <em>n</em> transitions using:</p><p><strong>πₙ = π₀ × Pⁿ</strong></p><p>Let’s compare the probability distributions after the first two transitions.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*YXvaRjn6NgmgT3aN91Uf7w.png" /></figure><p>Notice that the probability of being in the Submitted state increases in both scenarios. However, the probabilities are different because the projects started in different states.</p><p><strong>But what happens in the long run?</strong></p><p>In our transition matrix, <strong>Submitted is an absorbing state</strong>. Once the project reaches Submitted, it cannot return to Coding, Debugging, or Testing.</p><p>Furthermore, Submitted can be reached from every other state. In fact, every unfinished state has at least a 10% probability of transitioning directly to Submitted in the next session.</p><p>Therefore, as the number of transitions increases, the probability of remaining in an unfinished state approaches zero.</p><p>Eventually, both initial distributions converge to:</p><p><em>π</em>*<em> = [0, 0, 0, 1]</em></p><p>Mathematically:</p><p><strong>lim (n → ∞) π₀Pⁿ = [0, 0, 0, 1]</strong></p><p>This distribution is also stationary because multiplying it by the transition matrix does not change it:</p><p><strong>π</strong>*<strong><em>P = π</em></strong>*</p><p><strong>Conclusion:</strong> Both scenarios converge to the same stationary distribution, regardless of whether the project starts in Coding or Testing. The initial state affects the probability distribution in the short term, but not the limiting distribution in this particular Markov Chain.</p><h3>Bonus Challenge 3 : Can a Markov Model Predict Your Next Message in League of Legends?</h3><p>Imagine you’re playing League of Legends, and your team desperately needs a tank. While you’re typing in the team chat, an AI-powered autocomplete system tries to predict your next word.</p><p>Our AI uses a <strong>first-order Markov model</strong>, meaning it predicts the next word based only on the most recently typed word.</p><p>After analyzing thousands of game-chat messages, the model learns the following transition probabilities.</p><h3>Transition Probabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*krwjlHGn_oImU2ZKuD7SKw.png" /></figure><h4>Question 3.A — Sequence Probability</h4><p>Suppose you’ve already typed <strong>“we”</strong> in the team chat.</p><p>What is the probability that the AI will predict the next three words to complete the message:</p><p><strong>“we need a tank”</strong></p><h4>Question 3.B — The First-Order Markov Assumption</h4><p>Our model predicts each word using only the previous word.</p><p>For example, after seeing the word <strong>“a”</strong>, it always predicts “tank” with a probability of 0.40, regardless of the earlier words.</p><p>Why might this assumption be unrealistic for natural language?</p><h4>Question 3.C — Second-Order Markov Models</h4><p>Suppose we upgrade our AI to a <strong>second-order Markov model</strong>.</p><p>How would its predictions change? What advantage would this offer, and what disadvantage might it introduce?</p><h3>Solutions 3</h3><h4>Answer 3.A — Calculating Sequence Probability</h4><p>We already know that the first word is “we”. Therefore, we only need to calculate the probabilities of the next three transitions.</p><p>Our required sequence is:</p><p><strong>we → need → a → tank</strong></p><p>From the transition tables:</p><ul><li>P(need | we) = 0.60</li><li>P(a | need) = 0.50</li><li>P(tank | a) = 0.40</li></ul><p>Since our model follows the first-order Markov assumption, we can multiply these transition probabilities.</p><p><strong>P(“need a tank” | “we”) = 0.60 × 0.50 × 0.40 = 0.12</strong></p><p><strong>Final Answer: 12%</strong></p><p>There is a 12% probability that the next three words will be exactly “need a tank”, given that we have already typed “we”.</p><p>Notice that we did not include the probability of typing “we”, because the question tells us that this word has already been typed.</p><h4>Answer 3.B — Why Is the First-Order Markov Assumption Limited?</h4><p>A first-order Markov model assumes that the next word depends only on the most recently typed word, not the entire conversation.</p><p>Let’s consider two messages:</p><p><strong>Message 1:</strong> “We need a…”</p><p><strong>Message 2:</strong> “Let’s take a…”</p><p>Both messages end with the word “a”. According to our first-order model, the probability distribution of the next word must be identical for both messages.</p><p>However, their meanings are different. After “We need a”, the word “tank” might be a reasonable prediction. After “Let’s take a”, the word “break” might be more appropriate.</p><p>Our model cannot recognize this difference because it only remembers the last word.</p><p><strong>Conclusion:</strong> The first-order Markov assumption can be unrealistic for natural language because the next word often depends on multiple previous words. By considering only the most recent word, the model loses important contextual information.</p><h4>Answer 3.C — What Changes With a Second-Order Markov Model?</h4><p>A second-order Markov model considers the <strong>last two words</strong> instead of just the last one.</p><p>In our first-order model, we use:</p><p><strong>P(next word | previous word)</strong></p><p>In our second-order model, we use:</p><p><strong>P(next word | previous two words)</strong></p><p>For example, instead of predicting the next word based only on “a”, the model could distinguish between:</p><ul><li>P(tank | need, a)</li><li>P(tank | take, a)</li></ul><p>These probabilities could be different because the model now considers more context.</p><p>This can improve predictions, especially when the most recent word alone does not provide enough information.</p><p><strong>But what’s the disadvantage?</strong></p><p>A second-order model must learn and store probabilities for many more word combinations.</p><p>If our vocabulary contains V possible words:</p><ul><li><strong>First-order model:</strong> Up to V² transition probabilities.</li><li><strong>Second-order model:</strong> Up to V³ transition probabilities.</li></ul><p>For example, with a vocabulary of 1,000 words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Ue1an4wKoO20yhXl2HhasA.png" /></figure><p>These are theoretical table sizes, not necessarily the number of transitions observed in actual messages.</p><p>The second-order model requires more memory and more training data. Some combinations of words may also appear very rarely, making their transition probabilities difficult to estimate reliably.</p><p><strong>Conclusion:</strong> A second-order Markov model can capture more context and make better predictions, but this comes at the cost of increased complexity, memory usage, and training-data requirements.</p><h4>Final Takeaway</h4><p>Our simple game-chat example demonstrates three important concepts:</p><ol><li><strong>Sequence Probability:</strong> We multiply the probabilities of consecutive transitions to calculate the probability of a particular sequence.</li><li><strong>First-Order Markov Assumption:</strong> The next word depends only on the most recent word, which can cause the model to lose important context.</li><li><strong>Second-Order Markov Model:</strong> Considering the previous two words provides more context, but increases the model’s complexity.</li></ol><p>The key lesson is that <strong>remembering more history can improve predictions, but it also makes our Markov model more expensive to build and train.</strong></p><p>And if our autocomplete keeps suggesting “take a break” after every lost ranked game, maybe it’s trying to tell us something.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fc0f5651d23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Markov Models: Does Your Starting Money Matter? (Part 3 — Extra: Gambler’s Ruin)]]></title>
            <link>https://medium.com/@mhmt_onal/understanding-markov-models-does-your-starting-money-matter-part-3-extra-gamblers-ruin-859561ecadc9?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/859561ecadc9</guid>
            <category><![CDATA[markov-models]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[markov-chains]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 08:13:16 GMT</pubDate>
            <atom:updated>2026-10-18T08:13:16.558Z</atom:updated>
            <content:encoded><![CDATA[<h3>Welcome Back, Fellow Markov Model Nerds!</h3><p>Remember our frustrated League of Legends player? In Part 3, we discovered something interesting: even though our player could start in different roles, the probability distributions eventually approached the same stationary distribution. But does that mean the starting state never matters in the long run? <strong>Not necessarily!</strong></p><p>To understand why, let’s explore another classic problem in probability theory called <strong>Gambler’s Ruin</strong>. This time, instead of switching between LoL roles after losing games, we’ll follow a gambler who keeps winning or losing money. And surprisingly, their starting amount of money can make a big difference in the long run!</p><h3>1. What Is Gambler’s Ruin?</h3><p>Imagine a gambler who starts with <strong>$50</strong> and wants to reach <strong>$75</strong>. In each round, the gambler has a 50% chance of winning $25 and a 50% chance of losing $25. The game continues until the gambler either loses everything or reaches the target amount of $75. Once either outcome occurs, the game ends.</p><p>Our goal is to answer a simple question: <strong>Does the amount of money we start with affect our probability of eventually reaching $75?</strong> Let’s use Markov Chains to find out!</p><h3>2. Defining Our States</h3><p>Remember how each state in our LoL model represented a role such as ADC, Jungle, Top, or Mid? This time, each state represents the gambler’s current amount of money.</p><p>Our state space consists of four possible values: <strong>$0, $25, $50, and $75</strong>. For example, if the gambler currently has $50, winning the next round moves them to $75, while losing moves them to $25. Similarly, if the gambler has $25, winning moves them back to $50, while losing brings them to $0.</p><p>Notice something familiar? The gambler’s next state depends only on their current amount of money, not on how they reached that amount. In other words, we don’t need to know their entire history of wins and losses to predict the next state. <strong>That’s exactly the first-order Markov property!</strong></p><h3>3. Introducing Absorbing States</h3><p>Here’s something different from our League of Legends model. What happens when the gambler reaches $0? They have no money left, so the game ends. And what happens when they reach $75? They’ve achieved their target, so the game ends again.</p><p>These two states are called <strong>absorbing states</strong>. An absorbing state is a state that cannot be left once it has been reached. Mathematically, the probability of remaining in an absorbing state is 1. Therefore, in our example, both $0 and $75 are absorbing states, while $25 and $50 are non-absorbing states.</p><p>This small difference will have a significant effect on the long-term behavior of our Markov Chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qg8_R0oDTjCgwWInsxOdTg.png" /></figure><h3>4. Building Our Transition Matrix</h3><p>Now that we’ve defined our states, let’s construct the transition probability matrix. Just like in our previous articles, each row represents the current state, and each column represents the state after one transition. We’ll use the following order: <strong>[0, 25, 50, 75]</strong>.</p><p>If the gambler has $0, they remain at $0 with probability 1. If they have $25, they can either lose and move to $0 or win and move to $50, each with probability 0.5. From $50, they can move to $25 or $75 with probability 0.5 each. Finally, once they reach $75, they remain there with probability 1 because the game has ended.</p><p>Therefore, we can represent our Markov Chain using the following transition matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*WetmiSaJOKJt-bXWYtZVvw.png" /></figure><p>Notice that every row sums to 1, because the gambler must end up in one of the possible states after each transition. Also, pay attention to the first and last rows: their self-transition probabilities are 1, which confirms that $0 and $75 are absorbing states.</p><h3>5. Let’s Calculate Our First Two Transitions!</h3><p>Suppose our gambler starts with exactly $50. Since we know the starting state with certainty, our initial probability distribution is <strong>π₀ = [0, 0, 1, 0]</strong>. This means the probability of starting with $50 is 100%, while the probabilities of starting in the other states are zero.</p><p>Remember the formula we used in Part 2 to calculate the next probability distribution? We multiply our initial distribution by the transition matrix. Let’s do the same thing here!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*9QMidjFIReCaLYzTZ-bY4Q.png" /></figure><p>After the first round, there’s a 50% probability that our gambler has $25 and a 50% probability that they’ve already reached the target of $75. But what if we apply the transition matrix one more time? Using the same formula, we can calculate the distribution after two rounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*Oemnlj-LJYNt1VgB_6L2qQ.png" /></figure><p>Interesting! After two transitions, there’s a 25% probability that our gambler has lost everything, a 25% probability that they’re back at $50, and a 50% probability that they’ve already reached $75. Notice that the probability of reaching $75 remains at least 50% because once the gambler reaches that absorbing state, they cannot leave it.</p><p>But what happens if we continue multiplying our probability distribution by the transition matrix? Will we eventually reach a stationary distribution, just like in our LoL model?</p><h3>6. What Happens in the Long Run?</h3><p>In Part 3, we discovered that different starting roles eventually led to the same stationary distribution. However, Gambler’s Ruin behaves differently. As the number of transitions increases, the probabilities of being at $25 or $50 approach zero, because the gambler eventually reaches one of the two absorbing states with probability 1.</p><p>But here’s the interesting part: <strong>the probabilities of ending at $0 and $75 depend on how much money the gambler started with!</strong> To see this, let’s look at the long-run transition matrix that describes what happens as the number of transitions approaches infinity.</p><h4>Long-Run Transition Matrix</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*fLnMXZqzNT3avCDU4RpZtQ.png" /></figure><p>Let’s take a closer look at our long-run transition matrix, T∞. Remember our League of Legends model? In that example, every row of the long-run transition matrix approached the same probability distribution. However, in Gambler’s Ruin, <strong>the rows are not identical!</strong></p><p>First, notice that the second and third columns, representing $25 and $50, contain only zeros. This means that as the number of transitions approaches infinity, the probability of finding our gambler in either of these states approaches zero. Eventually, the gambler will reach one of the two absorbing states: $0 or $75.</p><p>Now, let’s focus on the second and third rows to answer our main question: <strong>Does the starting amount of money matter?</strong></p><p><strong>Starting with $25 (Row 2):</strong> Our initial probability distribution is π₀ = [0, 1, 0, 0]. Multiplying this distribution by T∞ gives us the second row of the matrix:</p><p><strong>π∞ = [2/3, 0, 0, 1/3]</strong></p><p>This means our gambler has a <strong>66.67% chance of losing everything</strong> and a <strong>33.33% chance of reaching $75</strong>.</p><p><strong>Starting with $50 (Row 3):</strong> This time, our initial probability distribution is π₀ = [0, 0, 1, 0]. Multiplying it by T∞ gives us the third row:</p><p><strong>π∞ = [1/3, 0, 0, 2/3]</strong></p><p>Now the situation is reversed! Our gambler has only a <strong>33.33% chance of losing everything</strong> and a <strong>66.67% chance of reaching $75</strong>.</p><p><strong>Wait a minute!</strong> By starting with just $25 more, our gambler doubles their probability of reaching the target. Unlike our LoL model, the initial state still matters in the long run!</p><h3>7. Wait… Where Did 1/3 and 2/3 Come From?</h3><p>We’ve seen that starting with $25 gives us a 1/3 chance of success, while starting with $50 increases that probability to 2/3. But here’s a question: <strong>where did those fractions actually come from?</strong></p><p>Did we really need to multiply our transition matrix hundreds of times to find them? <strong>Fortunately, no!</strong> We can calculate these probabilities directly using a method called <strong>First-Step Analysis</strong>.</p><p>The idea is simple: instead of looking at the entire future of the game, we examine what can happen in the next round and use those possibilities to calculate the eventual probability of success.</p><p>Let’s define <strong>h(x)</strong> as the probability of eventually reaching $75 when starting with $x. We already know two things: h(0) = 0 because the gambler has lost everything, and h(75) = 1 because the gambler has already reached the target.</p><p>Now, let’s examine our two remaining states.</p><p><strong>Starting with $25:</strong> The gambler has a 50% chance of losing $25 and reaching $0, or a 50% chance of winning $25 and moving to $50. Therefore, the probability of eventually reaching $75 can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*epOKRokHdEI0Kw9qaYh31Q.png" /></figure><p><strong>Starting with $50:</strong> The gambler has a 50% chance of moving to $25 and a 50% chance of reaching $75 immediately. Therefore:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*ON1r3WFzlrzCbkxP5objQw.png" /></figure><p>Great! We now have two equations with two unknowns. Let’s substitute our first equation into the second one and solve for h(50).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*ir5J9XxHSKPDf7nwEwVodw.png" /></figure><p>Now that we know h(50), calculating h(25) is easy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*UUYvh2gzOpVU04Beh9BIxw.png" /></figure><p>And there we have it! Starting with $25 gives our gambler a <strong>1/3 (33.33%) chance of reaching $75</strong>, while starting with $50 gives a <strong>2/3 (66.67%) chance</strong>. These are exactly the same probabilities we found in our long-run transition matrix!</p><p>But here’s something even more interesting. For a fair Gambler’s Ruin game like ours, where each round has an equal probability of winning or losing the same amount, we can use a simple shortcut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*JhHgUP0TGDqD0GAo1WRlZA.png" /></figure><p>For example, starting with $25 gives us 25/75 = 1/3, while starting with $50 gives us 50/75 = 2/3. Of course, this formula assumes a fair game with equal-sized wins and losses, absorbing boundaries at zero and the target, and starting amounts that lie on the game’s reachable state grid.</p><p><strong>Two different methods, same result!</strong> We calculated the long-term probabilities using our transition matrix and then verified them using First-Step Analysis.</p><h3>8. Final Thoughts — Why Does the Starting State Matter?</h3><p>So, why did our League of Legends model eventually forget its starting state while Gambler’s Ruin did not?</p><p>In our LoL model, every role could transition to every other role, including itself, with a positive probability. As a result, the probability distribution approached the same unique stationary distribution regardless of the player’s starting role.</p><p>In Gambler’s Ruin, however, <strong>$0 and $75 are absorbing states</strong>. Once the gambler reaches either one, the process stays there. Although the probability distributions still converge, their long-term values depend on the starting amount of money.</p><p><strong>The key takeaway:</strong> Not every Markov Chain converges to the same stationary distribution from every starting point. Our LoL model does, but Gambler’s Ruin can converge to different stationary distributions depending on where we start.</p><p>And that’s it, fellow Markov Model nerds! We started this series with a frustrated League of Legends player and ended up calculating a gambler’s probability of going broke. Who knew Markov Chains could connect such different problems?</p><p><strong>So, does your starting point matter? Well… it depends on the Markov Chain!</strong></p><p>Thanks for reading, and see you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=859561ecadc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Markov Models: Does Your Starting LoL Role Really Matter? (Part 3)]]></title>
            <link>https://medium.com/@mhmt_onal/understanding-markov-models-does-your-starting-lol-role-really-matter-part-3-7b641b04daa4?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b641b04daa4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[markov-models]]></category>
            <category><![CDATA[markov-chains]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 07:40:24 GMT</pubDate>
            <atom:updated>2026-10-18T08:16:27.003Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome back, fellow Markov Model nerds!</p><p>Looks like you still haven’t escaped League of Legends. Don’t worry, neither have I! (Right before writing this article, I lost three games in a row: started in top lane, switched to Jungle, and finally lost in Mid.)</p><p><strong>In Part 1, </strong>we learned how Markov Chains work by modeling a frustrated LoL player who keeps switching their role after losing games.</p><p><strong>In Part 2,</strong> we introduced Initial Probability Distributions and presented two different scenarios</p><blockquote>Scenario 1 : We knew that our player started as ADC</blockquote><blockquote>Scenario 2 : We didn’t know the starting role. So we assumed all four roles were equally likely (but the probability dist. can also be random )</blockquote><p>Even though we started with different probability distributions, something happened. After repeatedly applying the same transition probability matrix both scenarios approached almost exactly the same probabilities</p><p><strong>π ≈ [0.2857, 0.2698, 0.1587, 0.2857]</strong></p><h4>→ Wait a minute…</h4><p>In first scenario, we were very sure our player started as ADC role. In the other, we didn’t know our player’s starting role so we assigned equal probabilities to each role for the first game.</p><blockquote>Does this mean our starting role doesn’t matter?</blockquote><blockquote>Will every Markov Chain eventually behave this way?</blockquote><blockquote>And why do our probabilities seem to stop changing even though our player keeps switching roles?</blockquote><p>YESS THAT’S THE POINT → To answer the questions above we will explore two important concepts :</p><p><strong>Convergence and Stationary Distribution.</strong></p><h3>Convergence — Why Do Different Starting Points Lead to the Same Result?</h3><blockquote>Why does the difference between our two probability distributions get smaller after each transition?</blockquote><p>→ Even though our initial probability distributions were different, the difference between them became smaller after each transition. Eventually, both distributions approached the same values.</p><p><strong>→ This behavior is called convergence.</strong></p><p>→ In simple terms, convergence means that a sequence of probability distributions gets closer and closer to a particular distribution as we repeat the process.</p><p>Instead of jumping directly into formulas, let’s first visualize what convergence looks like.<br>We will compare the probability of playing <strong>ADC</strong> over several transitions in two different scenarios:</p><ul><li><strong>Scenario 1:</strong> The player starts as ADC.</li><li><strong>Scenario 2:</strong> All four roles are equally likely at the beginning.</li></ul><p>If both curves approach the same fixed value as the number of transitions increases, we’re observing convergence in the probability of playing ADC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*6b4we5AyJ5fyQNOWrGLL6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*eGaTXpJd_rJRzjVh07sTjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*kvJYqzciwq8hERE2OHYfOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*jGqFWnvhfNqOXRzwwiHq0g.png" /></figure><p>As we can see, the two scenarios start with very different probabilities.</p><p>In Scenario 1, the probability of playing ADC starts at 100%, while in Scenario 2, it starts at 25%.</p><p>However, after each transition, the difference between them becomes smaller.</p><p>After approximately 10 transitions, both probabilities are extremely close to 28.57%.</p><p><strong>This is exactly what convergence looks like!</strong></p><p>Even though we started from different initial distributions, the probabilities eventually approach the same long-term value.</p><h3>But What Happens Once the Distribution Stops Changing?</h3><p>→ We’ve just seen that our probability distributions get closer and closer to the same long-term values.</p><p>But here’s another interesting question:</p><blockquote><strong>What if we start directly from that long-term distribution and apply our transition matrix one more time?</strong></blockquote><blockquote>Will the probabilities change again?</blockquote><blockquote>Surprisingly, in our example, they won’t!</blockquote><p>This brings us to another important concept in Markov Chains: <strong>Stationary Distribution</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*oBU_nUMb0U0DsxL4WamfKA.png" /></figure><p>In simple terms, a stationary distribution is a probability distribution that remains unchanged after applying the transition matrix. Remember how we calculated our next probability distribution in Part 2?</p><p><strong>π₁ = π₀ × P</strong></p><p>We multiplied our current probability distribution by the transition matrix to get the next distribution. But now, something interesting happens. If we start with a stationary distribution and multiply it by the same transition matrix, <strong>we get exactly the same distribution back!</strong></p><p>That’s why we write:</p><p>π* × P = π*</p><p>Here, π* represents the stationary distribution, and P is our transition probability matrix.</p><h3>Let’s Verify It Using Our LoL Model!</h3><p>Remember the long-term probability distribution we calculated in Part 2?</p><p><em>π </em>* <em>≈ [0.2857, 0.2698, 0.1587, 0.2857]</em></p><p>Now, let’s multiply this distribution by our transition probability matrix one more time.</p><h4>What do we get?</h4><p>Almost exactly the same probabilities!</p><p><strong>This is what makes our distribution stationary.</strong></p><p>But remember, this doesn’t mean our player has stopped switching roles. It only means that the probability distribution remains unchanged.</p><h3>Step 1 — Recall Our Stationary Distribution</h3><p>In long term run we approached this distribution :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*bxLZqupqvniEx0ACDkyZvA.png" /></figure><h3>Step 2 — Recall Our Transition Matrix</h3><p>Our transition matrix is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*Er-vx4lGfNr7lPOL-u17cg.png" /></figure><h3>Step 3— Multiply by Our Transition Matrix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*bwuzCeSEvbTvZ8qDoD5wcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*AkP2pgKG3mNzpsaao_SGGw.png" /></figure><p>Result :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*ys-qn4Rvp9PdZaK7MHTkOg.png" /></figure><p>This equality holds exactly for the true stationary distribution. Since we are using rounded numbers here, our verification is approximate.</p><pre>import numpy as np<br>P = np.array([<br>    [0.4, 0.2, 0.1, 0.3],<br>    [0.2, 0.4, 0.2, 0.2],<br>    [0.2, 0.3, 0.3, 0.2],<br>    [0.3, 0.2, 0.1, 0.4]<br>])<br># Start from ADC and approach the stationary distribution<br>pi = np.array([1.0, 0.0, 0.0, 0.0])<br>for _ in range(100):<br>    pi = pi @ P<br># Apply the transition matrix one more time<br>next_pi = pi @ P<br>print(&quot;Stationary distribution:&quot;, np.round(pi, 6))<br>print(&quot;After one more step:   &quot;, np.round(next_pi, 6))<br>print(&quot;Are they equal?&quot;, np.allclose(pi, next_pi))</pre><pre>Stationary distribution: [0.285714 0.269841 0.15873  0.285714]<br>After one more step:    [0.285714 0.269841 0.15873  0.285714]<br>Are they equal? True</pre><blockquote>np.allclose() checks whether two arrays are approximately equal by allowing for very small numerical differences.</blockquote><p>→ Now here’s another interesting question:</p><blockquote><strong>Do we really need to multiply our matrix 100 times to find the stationary distribution?</strong></blockquote><p>Fortunately, no! And this brings us to an interesting connection between <strong>Markov Chains </strong>and <strong>linear algebra</strong>: <strong><em>Eigenvectors and Eigenvalues.</em></strong></p><h3>Finding the Stationary Distribution Without Repeated Multiplication</h3><p>We already know that a stationary distribution remains unchanged when multiplied by the transition matrix. But what if we don’t know the stationary distribution yet? Ok then, let’s represent using four unknown variables</p><p><em>π </em>* <em>= [a, b, c, d]</em> → <em>π is our stationary distribution symbol and </em><strong>a</strong> represents ADC, <strong>b </strong>represents Jungle, <strong>c </strong>represents Top, and <strong>d </strong>represents Mid. Our goal is to find these four probabilities. By solving this system, we can find our stationary distribution directly, without repeating the matrix multiplication 100 times!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*ulVgssdcygTPBQXd_Lofcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*D-26Ez_2v_UOAkyBcEz_UQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*VtPTJ-Q7pRtHZBEfRoIm1A.png" /></figure><p><strong>Look at Equation 1 and Equation 4. If we subtract Equation 4 from Equation 1, we get:</strong></p><p>a − d = 0.1a − 0.1d</p><p><strong>Move everything to one side:</strong></p><p>0.9a − 0.9d = 0 → <strong>a = d</strong></p><blockquote>Interesting! We’ve just discovered that ADC and Mid have equal probabilities in our stationary distribution.</blockquote><p>Now, let’s use Equation 3:</p><p>0.1a + 0.2b + 0.3c + 0.1d = c</p><p>Since we already know that a = d, we can replace d with a:</p><p>0.2a + 0.2b + 0.3c = c → 0.2a + 0.2b = 0.7c</p><p>Divide both sides by 0.7:</p><p><strong>c = (2/7)(a + b)</strong></p><blockquote>Great! We have now expressed c using only a and b.</blockquote><p>Let’s move to Equation 2:</p><p>0.2a + 0.4b + 0.3c + 0.2d = b</p><p>Again, substitute d = a:</p><p>0.4a + 0.4b + 0.3c = b → 0.6b = 0.4a + 0.3c</p><p>From Step 3, we know that:</p><p>c = (2/7)(a + b) — &gt; 0.6b = 0.4a + 0.3 × (2/7)(a + b)</p><p>Multiply both sides by 35 to eliminate the fractions:</p><p>21b = 14a + 3(a + b) → 21b = 17a + 3b → 18b = 17a</p><p><strong>b = (17/18)a</strong></p><blockquote>Now we know the relationship between the probabilities of Jungle and ADC!</blockquote><p>We already know:</p><p><strong>(d = a) AND (b = a(17/18)) AND (</strong>c = (2/7)(a + b))</p><p>Substitute b = (17/18)a:</p><p>c = (2/7) × (35/18)a → <strong>c = (5/9)a</strong></p><blockquote>We have successfully expressed all four variables using only a!</blockquote><p>Remember that the sum of all probabilities must equal 1.</p><blockquote><strong>a + b + c + d = 1</strong></blockquote><blockquote><strong>a + (17/18)a + (5/9)a + a = 1</strong></blockquote><blockquote><strong>(7/2)a = 1</strong></blockquote><blockquote><strong>a = 2/7 ≈ 0.2857</strong></blockquote><p>Now we can calculate the remaining probabilities:</p><blockquote><strong>b = (17/18) × (2/7) = 17/63 ≈ 0.2698</strong></blockquote><blockquote><strong>c = (5/9) × (2/7) = 10/63 ≈ 0.1587</strong></blockquote><blockquote><strong>d = a = 2/7 ≈ 0.2857</strong></blockquote><h4>Finally, we get:</h4><blockquote><em>π</em>*<em> ≈ [0.2857, 0.2698, 0.1587, 0.2857]</em></blockquote><h4>Wait a minute!</h4><p>Yes! These are exactly the same probabilities that we approached by repeatedly multiplying our transition matrix in Part 2.</p><p>But this time, we didn’t need to perform 30 or 100 matrix multiplications.</p><p>Instead, we found the stationary distribution directly by solving a system of equations.</p><p><strong>Two different methods, same result!</strong></p><p>And here’s something even more interesting: our stationary distribution equation has a special connection to linear algebra.</p><blockquote><strong>Eigenvectors and Eigenvalues!</strong></blockquote><h3>Why Is the Stationary Distribution an Eigenvector?</h3><h4>First, What Is an Eigenvector?</h4><p>In linear algebra, when we multiply a matrix by a vector the resulting vector may change its direction and magnitude. However, some special vectors behave differently. When we multiply these vectors by a matrix, the result is simply the original vector multiplied by a constant. These special vectors are called <strong>eigenvectors</strong>, and the constants are called <strong>eigenvalues</strong>.</p><p>The general eigenvector equation is:</p><blockquote><strong>Av = λv</strong></blockquote><ul><li><strong>A:</strong> A square matrix</li><li><strong>v:</strong> A nonzero eigenvector</li><li><strong>λ (lambda):</strong> An eigenvalue</li></ul><p>In simple terms, an eigenvector stays on the same line after a matrix transformation, although its magnitude may change.</p><h4>Now, Let’s Return to Our LoL Model!</h4><p>Remember our stationary distribution equation?</p><p>π⁎ × P = π⁎</p><p>This equation tells us that when we multiply our stationary distribution by our transition matrix, we get exactly the same vector back. But what if we write it this way?</p><p>π⁎ × P = 1 × π⁎</p><p>Doesn’t that look familiar? Compare the two equations:</p><p><strong>Eigenvector equation: Av = λv</strong></p><p><em>Our stationary distribution equation: </em>π⁎ × P = 1 × π⁎</p><p>They describe the same kind of relationship! The only difference is that we represent our probability distribution as a row vector, so we multiply it from the left. That’s why our stationary distribution is called a <strong>left eigenvector</strong> of the transition matrix P.</p><blockquote>And what is its eigenvalue? <strong>λ</strong> = 1</blockquote><h4>What Does This Actually Mean?</h4><p>It means that our stationary probability distribution is a special vector that remains completely unchanged when multiplied by the transition matrix.</p><p>In our LoL example:</p><p><em>π</em>*<em> ≈ [0.2857, 0.2698, 0.1587, 0.2857]</em></p><p>Multiplying this distribution by P gives us approximately the same probabilities (the displayed values are rounded). So, we can say that our stationary distribution is a <strong>left eigenvector of P corresponding to the eigenvalue 1</strong>.</p><p><strong>But here’s an important detail:</strong> Not every eigenvector is a valid stationary distribution. Its values must be non-negative and add up to 1. And remember, this doesn’t mean our player will stop switching roles! It simply means that the overall probability distribution remains unchanged. Pretty cool, right? We started with a frustrated League of Legends player switching roles after every loss, and somehow ended up discovering a connection to linear algebra!</p><h3>Does Every Markov Chain Behave Like Our LoL Model?</h3><p>So far, we’ve seen that our probability distributions approach the same stationary distribution, regardless of the starting role. But does this happen in every Markov Chain? <strong>Not necessarily!</strong></p><p>Some Markov Chains contain <strong>absorbing states</strong>, which are states that cannot be left once entered. For example, imagine a gambler who keeps playing until they either lose all their money or reach a target amount.Staying true to our League of Legends theme, imagine our frustrated player either switches to playing <strong>ARAM</strong> exclusively or <strong>rage-quits and uninstalls the game</strong>, never returning to standard roles again! Or suppose they discover a “broken” champion in Top lane and become a permanent One-Trick Pony (OTP) there. Once either outcome occurs, the game ends. Unlike our LoL model, the long-term probabilities of these outcomes can depend on how much money the gambler had at the beginning.</p><p>There are also other situations where a Markov Chain may fail to converge to a fixed distribution. <strong>The key takeaway:</strong> Our LoL model approaches the same stationary distribution from every starting role, but we cannot assume that every Markov Chain behaves this way.</p><h3>Final Thoughts</h3><p>And that’s it, fellow Markov Model nerds!</p><p>In Part 1, we learned how Markov Chains work by modeling a frustrated League of Legends player. In Part 2, we explored initial probability distributions and how they affect our predictions. And in Part 3, we discovered how different starting points can eventually lead to the same long-term distribution.</p><p>Along the way, we explored <strong>Convergence, Stationary Distribution, Systems of Equations, Eigenvectors, and Eigenvalues</strong>. We also learned that not every Markov Chain behaves the same way.</p><p>So, does your starting LoL role really matter with markov models? <strong>In the short term, yes! But in the long run, not in our model.</strong></p><p>And remember, reaching a stationary distribution doesn’t mean our player will stop switching roles. It simply means that the probabilities of playing each role remain unchanged.</p><p>Thanks for reading, and see you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b641b04daa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Markov Models: Can We Predict Your Future Roles? (Part 2)]]></title>
            <link>https://medium.com/@mhmt_onal/understanding-markov-models-can-we-predict-your-future-roles-part-2-54af11d0b988?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/54af11d0b988</guid>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 05:22:09 GMT</pubDate>
            <atom:updated>2026-10-18T05:22:09.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome back !</p><p>In part1, we learned Markov Models through a concrete League of Legends example (If you have never played LoL maybe I can optimize this example to general example [maybe])</p><p>We learned that even seemingly random decisions might follow a probability pattern.</p><p>Before diving into more advanced conpcepts, I want to review what we have learned so far.</p><h3><strong>Quick Recap</strong></h3><ol><li><strong>States and Transitions : </strong>Our model consists of 4 states: ADC, Jungle, Mid, Top. Actually each state represents the role you are playing. Transition represents your decision to stay in the same role or switch to another one.</li><li><strong>Transition Probabilities: </strong>Each transition has a probability. For example, if you are currently playing ADC there is a 20% chance you will switch to Jungle.</li><li><strong>The Markov Property: </strong>Our model follows a simple assumption: your next role depends on only your current role. Not on your entire match history!</li><li><strong>Time-Homogeneity: </strong>We assume that our transition probabilities remain constant over time</li></ol><p>5. <strong>Transition Probability Matrix: </strong>We represented all the probabilities using a transition matrix P. Each row represents your current role and each column represents your next possible role. The probabilities in each row add up to 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2ilI4ZhQSibS_XXzr1CCQ.png" /></figure><h4>What if we don’t know which role we’re starting from?</h4><p>→This brings us to our next concept: Initial Probability Distribution.</p><h3>Initial Probability Distribution — Where Do We Start?</h3><p>Greetings, fellow Markov Model nerds! Although there are a number of sources to learn about Markov Models, you somehow ended up here again. I guess you haven’t had enough of League of Legends and probability yet!</p><blockquote><strong>What if we don’t know which role our player is currently playing?</strong></blockquote><p>I’m asking: What if we don’t know the current state?? Can we calculate the probabilities of the next states? Even if we don’t have any starting information…</p><p>This is where the <strong>Initial Probability Distribution </strong>comes into play. Saying that we do not know the initial role doesn’t mean we cannot make any assumptions about the initial probabilities.</p><h3>Two Different Scenarios</h3><p>Before moving forward let’s imagine there are two different scenarios related to our LoL example.</p><p>In both scenarios, we’ll use same four roles(states) : ADC, Jungle, Top, Mid</p><p>The only difference is what we know about our player’s starting role.</p><h4>Scenario 1 — We Know the Starting Role</h4><p>Let’s say our player is playing ADC role. We know this information for sure!</p><p>Since we know the starting role, we can give 100% probability to ADC and 0% to the other roles for initial state.</p><p>Our initial probability distribution would be:</p><p><strong>π₀ = [1, 0, 0, 0]</strong></p><pre><br>import numpy as np<br><br>P = np.array([<br>    [0.4, 0.2, 0.1, 0.3],<br>    [0.2, 0.4, 0.2, 0.2],<br>    [0.2, 0.3, 0.3, 0.2],<br>    [0.3, 0.2, 0.1, 0.4]<br>])<br><br><br>pi = np.array([1.0, 0.0, 0.0, 0.0])<br><br><br>for step in range(1, 31):<br>    pi = pi @ P<br>    print(f&quot;After {step} losses: {np.round(pi, 4)}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*ew70Aq6b8pJ5A0gPJGsGfw.png" /></figure><p>As you can see from the code, we start with the assumption that our player’s initial role is ADC.After each loss we update our probability distribution using the same transition matrix.Interestingly, after approximately 15 losses the probabilities seem to stop changing!</p><p>Our distribution approaches: <strong>π ≈ [0.2857, 0.2698, 0.1587, 0.2857]</strong></p><p>This means that in the long run, our player has approximately a 28.57% chance of playing ADC, a 26.98% chance of playing Jungle, a 15.87% chance of playing Top, and a 28.57% chance of playing Mid.</p><p>But here’s an interesting question:</p><blockquote><strong>Will we reach the same probabilities if we don’t know our starting role?</strong></blockquote><h4>Scenario 2— We Don’t Know the Starting Role</h4><p>Imagine you are watching a LoL player but you have no idea which role they are currently playing. We still have four possible roles, this time we do not know the initial probabilities of any of them.</p><p>So, we can make some assumptions about the starting state -&gt;</p><p><strong>π(0) =[0.25, 0.25, 0.25, 0.25] ,</strong></p><p><strong>π(0) =[0.15, 0.35, 0.05, 0.45] ,</strong></p><p><strong>π(0) =[0.08, 0.23, 0.12, 0.57] ,</strong></p><blockquote>Notice that these are just hypothetical distributions. Without additional information, we cannot know which one best represents the player’s actual starting role.</blockquote><p>Let’s go forward with first assumption that each state has a 25% probability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*-075ToTPD-6ZSGl-BthRFA.png" /><figcaption>Transition Probability Matrix From Part 1</figcaption></figure><h4>Step 1 — Define Our Initial Probability Distribution (π₀)</h4><p>In Scenario 2, we don’t know which role our player is currently playing.</p><p>So, let’s assume that all four roles are equally likely.</p><p><strong>π(0) =[0.25, 0.25, 0.25, 0.25] ,</strong></p><p>This means there’s a 25% probability that our player starts in each role.</p><p>Now, let’s calculate the probability distribution after one loss.</p><h4>Step 2 — Calculate the Next Distribution (π₁)</h4><p>To calculate the probabilities after one transition, we multiply our initial probability distribution by the transition matrix.</p><p>But wait! Why do we multiply our initial distribution by the transition matrix??</p><p>In our previous scenario, we knew that our player started as ADC. But this time, the player might be starting in any of the four roles.</p><p>Suppose we want to calculate the probability of playing ADC after one loss. There are four possible ways to end up playing ADC:</p><ul><li>ADC → ADC</li><li>Jungle → ADC</li><li>Top → ADC</li><li>Mid → ADC</li></ul><p>Remember what we did in part1? We multiplied the probabilities along each path then added them together. Let’s use the same idea here!!!</p><h4>From Probability Calculations to Matrix Multiplication</h4><p>We just calculated the probability of playing ADC after one transition. But what about Jungle, Top, and Mid?</p><p>Of course we could repeat the same calculations for each role.</p><p>However there’s a much simpler way to calculate all four probabilities at once.</p><h3><strong>Matrix multiplication!</strong></h3><p>Yes! Matrix Multiplication!!</p><p>We represent our <strong>initial probability distribution</strong> as a row vector and our transition probabilities as a matrix.</p><p>When we multiply them, we get the probability distribution after one transition.</p><p><strong>π₁ = π₀ × P [basic dot product] [Multiply the row by each column separately and add up the results.]</strong></p><p>Where:</p><ul><li>π₀ = Initial probability distribution</li><li>P = Transition probability matrix</li><li>π₁ = Probability distribution after one transition</li></ul><p>This equation is simply a compact way of applying the same probability calculations to all four roles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*ZRWq0NdjOAhnBJAqubGeFg.png" /></figure><p>π₁ = [0.275, 0.275, 0.175, 0.275]</p><p>Now, let’s assume our player loses another game.</p><p>To calculate the probabilities after the second loss, we use the same transition probability matrix again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*5bvv8J3dQpZjsJgD3u96rA.png" /></figure><p>Substituting our values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*I-8ibgPloq5rHwDXRomvkw.png" /></figure><p>Let’s calculate each role’s probability :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8H98KZZgqXw6-qK2heB3Jg.png" /></figure><p>Our new probability distribution is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*n1MSuNlu3aGnwvcr4SECrg.png" /></figure><h4>What is the IMPORTANT POINT HERE??</h4><blockquote>Notice that we didn’t need to calculate every possible path manually. We simply multiplied our previous distribution by the same transition matrix.</blockquote><p>Since π₁ = π₀P, we can also write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*5qu9UIyETbdL1y8j2ZUvIA.png" /></figure><p>And this leads us to a more general equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*C-4tVmtDOw4zOn4NYGCRJA.png" /></figure><pre><br>import numpy as np<br><br>roles = [&quot;ADC&quot;, &quot;Jungle&quot;, &quot;Top&quot;, &quot;Mid&quot;]<br><br>P = np.array([<br>    [0.4, 0.2, 0.1, 0.3],<br>    [0.2, 0.4, 0.2, 0.2],<br>    [0.2, 0.3, 0.3, 0.2],<br>    [0.3, 0.2, 0.1, 0.4]<br>])<br><br>pi = np.array([0.25, 0.25, 0.25, 0.25])<br><br>print(&quot;Initial distribution:&quot;, pi)<br><br>for step in range(1, 31):<br>    pi = pi @ P<br>    print(f&quot;After {step} losses: {np.round(pi, 4)}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*wlj5TUEiW8TvhFLIyiClEA.png" /></figure><p>Interesting! We started with equal probabilities for all four roles, but after several losses, our probability distribution began to stabilize.</p><p>After approximately 15 transitions, the probabilities barely change anymore.</p><p>Our distribution approaches:</p><p><strong>π ≈ [0.2857, 0.2698, 0.1587, 0.2857]</strong></p><h3>→Wait a minute!</h3><p>Didn’t we get almost exactly the same results in Scenario 1, where we knew our player started as ADC?</p><h3>→Yes, we did!</h3><p><strong>Two different initial probability distributions, but the same long-term result.</strong></p><blockquote>So, does our starting role eventually stop mattering?</blockquote><blockquote>For our particular Markov Chain, yes. But why?</blockquote><blockquote>Is this just a coincidence, or is there a mathematical explanation?</blockquote><p><strong>In Part 3, we’ll explore Convergence and Stationary Distributions to understand why this happens.</strong></p><p>See you in the next game! 🎮</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54af11d0b988" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Markov Models: Can Your Last League of Legends Game Predict Your Next Role? (PART1)]]></title>
            <link>https://medium.com/@mhmt_onal/understanding-markov-models-can-your-last-league-of-legends-game-predict-your-next-role-part1-ab81fd9f2e64?source=rss-41acefd504e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab81fd9f2e64</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[markov-models]]></category>
            <category><![CDATA[markov-chains]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mehmet ONAL]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 04:33:17 GMT</pubDate>
            <atom:updated>2026-10-17T04:57:41.718Z</atom:updated>
            <content:encoded><![CDATA[<p>Yes!</p><p>Although there are a number of sources to learn about Markov Models or understand how they work, the bulk of them represent the topic in an abstract way. So, I wanted to try to move the topic from the abstract to the concrete. My approach to this topic is to use a very famous game.</p><p><strong>“League of Legends”</strong></p><p>Let’s say your team has been inting a lot lately and you’re changing lanes persistently. Maybe you’ve never realized it, but there could be a pattern.</p><p><strong>A probability pattern!</strong></p><p>There! Imagine you are playing the ADC role and your support is such a bad player that they keep dying. Even though you have a good KDA, your team surrenders at minute 15. You want to switch your lane. What is the probability that you will switch roles to Mid, Jungle or Top?</p><p><strong>A pattern that depends only on your current role!</strong></p><p>Let’s assume that after every loss, you decide which role to play in your next game. You can either stay in your current role or switch to another one.</p><p>Imagine a scenario where you keep losing games and reconsidering your role after each defeat. But what if we could predict your next role based only on your current role?</p><p>For example, you play ADC and win your lane, but unfortunately, your team loses the game. Even though you lost, you can still feel confident in this role because you performed well. So, you may want to play one more game in the ADC role.</p><p><strong>OR</strong></p><p>Let’s say you’re frustrated after another defeat and decide to switch your role to Jungle, Mid, or Top.</p><p>Each possible switch has its own probability.</p><h3>ADC</h3><ul><li>ADC → Jungle: 0.2(20%)</li><li>ADC → Top: 0.1 (10%)</li><li>ADC → Mid: 0.3 (30%)</li><li>ADC → ADC: 0.4 (40%)</li></ul><h3><strong>Jungle</strong></h3><ul><li>Jungle → ADC: 0.2(20%)</li><li>Jungle → Top: 0.2 (20%)</li><li>Jungle → Mid: 0.2 (20%)</li><li>Jungle → Jungle: 0.4 (40%)</li></ul><h3><strong>Top</strong></h3><ul><li>Top → ADC: 0.2 (20%)</li><li>Top → Jungle: 0.3 (30%)</li><li>Top → Mid: 0.2 (20%)</li><li>Top → Top: 0.3 (30%)</li></ul><h3><strong>Mid</strong></h3><ul><li>Mid → ADC: 0.3 (30%)</li><li>Mid → Jungle: 0.2 (20%)</li><li>Mid → Top: 0.1 (10%)</li><li>Mid → Mid: 0.4 (40%)</li></ul><p>Notice that even after losing, there’s still a 40% chance you’ll choose ADC again. After all, maybe the next game will be different!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*spkqNc71Q3yPPG9f5SXzWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oLIHFbkebrmQyvn0qjL48w.png" /></figure><blockquote>Okay, Mehmet, we understood the LoL example. Where is the Markov Model here?</blockquote><p>That’s definitely a necessary question right now.</p><h3>Formalizing the Model: States and Transitions</h3><p>To bridge our LoL example with the formal world of Markov Models, we just need to define two core concepts:</p><ul><li><strong>State (S): </strong>Represents the specific condition or situation the system is in at any given time step t. In our game, the <strong>States</strong> are the five roles you can play: <strong>ADC, Jungle, Top, Mid</strong> (and technically Support but I didn’t add it to my example because it makes the math complicated and I hate to play support). At any moment, you are in one and only one state.</li><li><strong>Transition (T):</strong> A transition is the movement from one state to another (or staying in the same state) as time progresses from step to step t+1 (e.g., changing from ADC to Jungle).</li><li><strong>Transition Probability Matrix (P):</strong> The collection of all these transition probabilities forms our transition matrix, where every row represents your current state and every column represents your next possible state.</li></ul><p>A first-order Markov Model doesn’t need the entire history to predict the next state; it uses only the current state. just like in our example.</p><p>In our example, if a player switches roles from ADC to Jungle; ADC the is current state and the next state is Jungle. The probability of this transition is 20%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*QEgW2BBSTIXB-TTzvMCdEA.png" /></figure><p>Understanding the Symbols</p><ul><li>Xₜ — The current role</li><li>Xₜ₊₁ — The role in the next game</li><li>P — Probability</li><li>| — Given that</li><li>0.2–20% probability,</li></ul><h3>The Markov Property — Does the Past Really Matter?</h3><blockquote>Do we really need to know your entire match history to predict your next role?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFhgTb7ZQLSJQmrGYpN3Gw.png" /></figure><p>The player played Top → Mid → Jungle → ADC in that order. According to the Markov property, we don&#39;t need to know the entire history. The first-order Markov property can be expressed as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*uzWEa_iK8Sfim6JBpbFEXA.png" /></figure><p>Here, the left side takes into account all past roles, whereas the right side uses only the current role.</p><h3><strong>What If You Lose 3 Games in a Row?</strong></h3><blockquote>If you start as an ADC and lose three games in a row, what’s the probability that you’ll end up playing Jungle?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*NKnH8fFpdpAgwLH76uoLBw.png" /></figure><p>P¹ = One transition (after 1 loss)</p><p>P² = Two transitions (after 2 losses)</p><p>P³ = Three transitions (after 3 losses)</p><h3>Step 1 — After Your First Loss (P¹)</h3><p>Let’s start with something simple.</p><p>Imagine you’re playing ADC and lose your first game. As we discussed earlier, you now have four possible choices for your next role.</p><p>According to our transition probability matrix:</p><ul><li>ADC → ADC: 40%</li><li>ADC → Jungle: 20%</li><li>ADC → Top: 10%</li><li>ADC → Mid: 30%</li></ul><p>We already know these probabilities because they are directly represented in the first row of our transition matrix.</p><p>In other words, <strong>P¹ represents the probabilities after one transition.</strong></p><blockquote>But what happens if you lose another game?</blockquote><h3>Step 2 — After Your Second Loss (P²)</h3><p>Things are getting more interesting!</p><p>Let’s say you lose another game. Now, we want to calculate the probability of playing Jungle after two consecutive losses.</p><p>Unlike the first step, we can’t simply look at the ADC → Jungle probability.</p><h4>Why?</h4><p>Because there are multiple possible paths to reach Jungle after two games.</p><p>For example, you might stay in ADC after your first loss and then switch to Jungle after your second loss.</p><p>Or you might switch to Jungle immediately and decide to stay there after losing again.</p><p>Let’s calculate all the possible paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*suQEWsPcpwMONaKGNvYCCg.png" /></figure><p><strong>→ Total Probability = 0.16 + 0.04 + 0.02 + 0.09 = 0.31 (31%)</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3gVgVZViDq_aYtamqkvQyw.png" /></figure><p><strong>→ Total Probability = </strong>0.12 + 0.04 + 0.02 + 0.12 = 0.30 (30%)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOZQ4DiIAiQavHlOTjwRFw.png" /></figure><p><strong>→ Total Probability = </strong>0.04 + 0.04 + 0.03 + 0.03 = 0.14 (14%)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXQIJCYdM54cGmaP8ct4Jw.png" /></figure><p><strong>→ Total Probability = </strong>0.08 + 0.08 + 0.03 + 0.06 = 0.25 (25%)</p><p>After calculating all possible paths, we get the following probabilities after two consecutive losses:</p><ul><li>ADC: 31%</li><li>Jungle: 25%</li><li>Top: 14%</li><li>Mid: 30%</li></ul><p>Notice that all four probabilities add up to 100%.</p><p>Even after two losses, ADC is still the most likely role, with a probability of 31%, followed closely by Mid at 30%.</p><p>These results represent the ADC row of P², which we obtain by multiplying the transition matrix by itself.</p><p><strong>P² = P × P</strong></p><p><strong>Wait… Do These Probabilities Ever Change? (Time-Homogeneity)</strong></p><p>Notice something we just did? When calculating our second loss, we used the exact same transition probabilities as our first loss. For instance, the probability of switching from ADC to Jungle remained 20% in both steps.</p><p>In the Markov world, this is called <strong>Time-Homogeneity</strong> (or a time-homogeneous Markov chain). It means our transition matrix remains constant over time — no matter the step. We assume you don’t get extra tilted at 3 AM and suddenly change your behavior; even when moving from your 50th loss to your 51st loss, we assume this exact same probability table still applies!</p><blockquote><strong>Now, keeping this rule in mind, what happens if you lose a third game (P³)? I will be waiting for your comments :)</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab81fd9f2e64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>