<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mitansh Gor</title>
    <description>The latest articles on DEV Community by Mitansh Gor (@mitanshgor).</description>
    <link>https://dev.to/mitanshgor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F999457%2F1e38e750-fe49-48f5-8f41-8b0a1ea57000.png</url>
      <title>DEV Community: Mitansh Gor</title>
      <link>https://dev.to/mitanshgor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mitanshgor"/>
    <language>en</language>
    <item>
      <title>RL 6: Pleasure-Seeking Neurons and the Birth of Backpropagation (1972–1980)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 10 Oct 2026 21:33:29 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-6-pleasure-seeking-neurons-and-the-birth-of-backpropagation-1972-1980-4b75</link>
      <guid>https://dev.to/mitanshgor/rl-6-pleasure-seeking-neurons-and-the-birth-of-backpropagation-1972-1980-4b75</guid>
      <description>&lt;p&gt;&lt;em&gt;Quick recap from Blog 5: Learning Automata could adapt to what was happening right now, but they were hopeless at delayed consequences. A chess move that loses you the game 20 turns later. A word that quietly breaks a sentence three clauses down. They had no way to connect "what I did" with "what happened much later."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post is about the two people who went after that gap, and the third person who spotted a problem hiding behind it. By the end you'll know what an eligibility trace is, how backpropagation actually works (with a tiny example), and why every modern AI system still runs on ideas from this decade.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  First, the problem in plain English
&lt;/h2&gt;

&lt;p&gt;Imagine you're baking cookies for the first time. At step 2 you accidentally dump in a tablespoon of salt instead of a teaspoon. You keep going: mix, chill, shape, bake. At step 50 (taste time) the cookies are awful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjl8rrx8qupy7bu4nlhn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjl8rrx8qupy7bu4nlhn0.png" alt="Cooking cookies baking" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now ask yourself: &lt;strong&gt;which step was the mistake?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You didn't taste anything at step 2. The feedback only showed up at the very end. To learn, you need a way to trace the bad result &lt;em&gt;back&lt;/em&gt; to the step that caused it. That's the &lt;strong&gt;credit assignment problem&lt;/strong&gt; (or "blame assignment", if you prefer): when something good or bad happens, which of your earlier decisions deserves the credit or the blame?&lt;/p&gt;

&lt;p&gt;By the early 1970s the field had two things that didn't talk to each other:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bellman's equations&lt;/strong&gt; (Blog 3): mathematically perfect and provably optimal, but they need a complete model of the world. Nobody has that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Samuel's checkers player and Tsetlin's automata&lt;/strong&gt; (Blogs 4 and 5): practical and adaptive, but with no theory behind them and no good answer for late-arriving consequences.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 1970s produced three ideas that started to close that gap. Here's the roadmap so you always know where we are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Klopf&lt;/strong&gt; gives a single neuron a &lt;em&gt;drive&lt;/em&gt; and a short &lt;em&gt;memory of what it just did&lt;/em&gt;. (Who gets credit, and when?)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Werbos&lt;/strong&gt; gives a whole network a &lt;em&gt;direction&lt;/em&gt;: a method to push blame backward through many layers. (How far back does the blame go?)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grossberg&lt;/strong&gt; adds a &lt;em&gt;warning&lt;/em&gt;: learn too eagerly and you'll erase what you already knew. (How do we keep our old skills?)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then we'll see how &lt;strong&gt;Adaptive Dynamic Programming&lt;/strong&gt; wired them together, and how it produced the Actor-Critic idea that still runs inside modern AI.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick glossary
&lt;/h2&gt;

&lt;p&gt;You'll see these words a lot. Don't memorize them, just glance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Neuron (artificial):&lt;/strong&gt; a tiny calculator. It takes numbers in, multiplies each by a &lt;em&gt;weight&lt;/em&gt;, adds them up, and outputs a result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weight:&lt;/strong&gt; how much the neuron "listens" to one particular input. Learning = adjusting weights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reward:&lt;/strong&gt; a number telling the system "that went well" (positive) or "that went badly" (negative).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expectation / baseline:&lt;/strong&gt; the reward the system &lt;em&gt;predicted&lt;/em&gt; it would get.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer:&lt;/strong&gt; a group of neurons. A network stacks layers: input -&amp;gt; hidden layers -&amp;gt; output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loss:&lt;/strong&gt; a single number measuring how wrong the output was. Lower is better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient:&lt;/strong&gt; a list of "if I nudge this weight a little, how much does the loss change?"&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Harry Klopf and the Hedonistic Neuron (1972)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05wyqbelnu8wyct40rpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05wyqbelnu8wyct40rpa.png" alt="Harry Klopf" width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most of the 1970s AI crowd was busy building symbolic systems: expert systems, logic provers, decision trees. Harry Klopf, a researcher at the US Air Force Cambridge Research Laboratories, was looking at a single neuron and asking something stranger.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What if the neuron isn't a passive wire? What if it wants something?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In his 1972 report, &lt;em&gt;Brain Function and Adaptive Systems: A Heterostatic Theory&lt;/em&gt;, Klopf proposed that neurons act like tiny &lt;strong&gt;hedonists&lt;/strong&gt;: pleasure-seekers that strengthen the connections that led to good outcomes and weaken the ones that didn't.&lt;/p&gt;

&lt;p&gt;That was a direct challenge to the textbook picture of a neuron as a threshold switch: inputs in, weighted sum, fire or don't. In that picture the neuron has no memory of outcomes and no preference about them. Klopf said that couldn't be the whole story.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6bzppbx0goas0barlwds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6bzppbx0goas0barlwds.png" alt="classics vs klopf neuron" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Heterostasis vs. homeostasis (the thermostat vs. the athlete)
&lt;/h3&gt;

&lt;p&gt;Biology textbooks of the time said living systems seek &lt;strong&gt;homeostasis&lt;/strong&gt;: balance and stability. Think of a &lt;strong&gt;thermostat&lt;/strong&gt;. It wants the room at 21°C. Hit 21 and it relaxes.&lt;/p&gt;

&lt;p&gt;Klopf proposed &lt;strong&gt;heterostasis&lt;/strong&gt;: a drive to push &lt;em&gt;beyond&lt;/em&gt; the comfortable state toward something better. Think of an &lt;strong&gt;athlete&lt;/strong&gt;. Hitting last month's personal best isn't "done", it's the new starting line.&lt;/p&gt;

&lt;p&gt;Why does this matter for AI? Because it reframes learning as &lt;em&gt;forward-looking&lt;/em&gt;. A thermostat-style learner stops when things are fine. A heterostat-style learner keeps asking "can I do better than I expected?" And that is exactly what reinforcement learning is.&lt;/p&gt;

&lt;h3&gt;
  
  
  The timing problem, and the eligibility trace
&lt;/h3&gt;

&lt;p&gt;Back to the cookies. Klopf hit the same wall: rewards arrive &lt;em&gt;after&lt;/em&gt; the action that caused them. When the reward finally shows up, how does the neuron know which of its recent activity deserves credit?&lt;/p&gt;

&lt;p&gt;His answer: the &lt;strong&gt;eligibility trace&lt;/strong&gt;. Think of it like &lt;strong&gt;a glowing footprint&lt;/strong&gt;. When a connection is active, it leaves a footprint that fades over time. If a reward arrives while the footprint is still glowing, that connection is "eligible" for credit. If the footprint has faded, it isn't.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpdv0rxo0u28at04xjxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpdv0rxo0u28at04xjxr.png" alt="eligibility trace" width="800" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a simplified teaching version of the idea as an update rule (Klopf's own later formulations got more elaborate, but this captures the heart of it):&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;ˉ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;τ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Let's read it piece by piece:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Δw_i&lt;/code&gt;: how much to change the weight on input &lt;code&gt;i&lt;/code&gt; (the "learning step").&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;α&lt;/code&gt; (alpha): the learning rate, i.e., how big a step to take.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r(t)&lt;/code&gt;: the reward you actually got.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r̄(t)&lt;/code&gt;: the reward you &lt;em&gt;expected&lt;/em&gt; to get.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x_i(t − τ)&lt;/code&gt;: the footprint, i.e., how active input &lt;code&gt;i&lt;/code&gt; was a moment ago.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The middle piece, &lt;code&gt;r − r̄&lt;/code&gt;, is the important one. It's &lt;strong&gt;surprise&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Got &lt;em&gt;more&lt;/em&gt; than expected (&lt;code&gt;r &amp;gt; r̄&lt;/code&gt;)? Strengthen whatever was recently active.&lt;/li&gt;
&lt;li&gt;Got &lt;em&gt;less&lt;/em&gt; than expected? Weaken it.&lt;/li&gt;
&lt;li&gt;Got exactly what you expected? Change nothing. Nothing to learn.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb1g14i860rjkdf2wbhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flb1g14i860rjkdf2wbhz.png" alt="surprise FACTOR" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; you order your usual coffee and it's good. No surprise, no learning. You try a new cafe, and the coffee is fantastic. Big positive surprise, and your brain strongly reinforces "go to &lt;em&gt;that&lt;/em&gt; cafe." Learning is driven by the &lt;em&gt;gap&lt;/em&gt;, not by the raw reward.&lt;/p&gt;

&lt;p&gt;Hold onto this "surprise" idea. In Blog 8, Richard Sutton turns it into the &lt;strong&gt;TD error&lt;/strong&gt;, which is arguably the most important quantity in all of RL. Klopf had the biological intuition first; the math came later.&lt;/p&gt;

&lt;p&gt;And the footprint idea didn't die either: modern algorithms called TD(λ) still use eligibility traces in essentially this form.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pause and check.&lt;/strong&gt; Can you say, in one sentence, why a neuron needs &lt;em&gt;both&lt;/em&gt; a surprise signal and an eligibility trace? (Surprise tells it &lt;em&gt;how much&lt;/em&gt; to change. The trace tells it &lt;em&gt;what&lt;/em&gt; to change.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Where we are:&lt;/strong&gt; Klopf gave a neuron a drive and a short memory. But a single neuron is tiny. What happens when you have layers of them, and the reward only connects to the last layer? That's the next problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  Paul Werbos and the Algorithm Nobody Read (1974)
&lt;/h2&gt;

&lt;p&gt;A neuron that &lt;em&gt;wants&lt;/em&gt; reward but can't figure out &lt;em&gt;which of its decisions caused it&lt;/em&gt; will thrash forever. And this gets brutal in multi-layer networks. If the final answer is wrong, which weight, in which layer, is responsible? In 1974, nobody had a practical answer for neural networks.&lt;/p&gt;

&lt;p&gt;Paul Werbos did. Getting anyone to pay attention was the hard part.&lt;/p&gt;

&lt;p&gt;In his 1974 Harvard PhD thesis, &lt;em&gt;Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences&lt;/em&gt;, Werbos described how to train multi-layer neural networks by propagating error &lt;strong&gt;backward&lt;/strong&gt; through the layers. Today we call this &lt;strong&gt;backpropagation&lt;/strong&gt; (often just "backprop").&lt;/p&gt;

&lt;h3&gt;
  
  
  Backprop without the scary math: the assembly line
&lt;/h3&gt;

&lt;p&gt;Picture a three-station assembly line making a gadget. Station 1 passes its work to Station 2, then Station 3, then the finished gadget gets inspected. The inspector says: "This is off by 6 millimeters."&lt;/p&gt;

&lt;p&gt;Whose fault is that? The inspector can only see the final product. But here's the trick:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Station 3 asks: "How much did &lt;em&gt;my&lt;/em&gt; output contribute to that error?" It can answer directly, because it's the last one.&lt;/li&gt;
&lt;li&gt;Station 3 tells Station 2: "Here's how sensitive the final result is to what you gave me."&lt;/li&gt;
&lt;li&gt;Station 2 uses that to work out its own share of blame, then tells Station 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Blame flows &lt;strong&gt;backward&lt;/strong&gt;, station by station, each one using what the next one told it. That's backpropagation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwffjs0isao2hnr6nznms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwffjs0isao2hnr6nznms.png" alt="Back prop" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The chain rule, with gears
&lt;/h3&gt;

&lt;p&gt;The math behind this is the &lt;strong&gt;chain rule&lt;/strong&gt; from calculus, and it's much friendlier than its name. Here's the idea with gears.&lt;/p&gt;

&lt;p&gt;Say turning Knob A by 1 unit moves Knob B by 3 units. And turning Knob B by 1 unit moves the final output by 2 units. Then turning Knob A by 1 unit moves the output by &lt;strong&gt;3 × 2 = 6 units&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's the whole chain rule: &lt;em&gt;when effects are chained together, you multiply the sensitivities&lt;/em&gt;.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;L&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;w&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;∂&lt;/span&gt;&lt;span class="mord mathnormal"&gt;z&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui9fm0loq9hrb1obpnsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui9fm0loq9hrb1obpnsp.png" alt="chain rule" width="600" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Translating the symbols:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;L&lt;/code&gt;: the loss (how wrong the final output was).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt;: a neuron's output (its "activation").&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;z&lt;/code&gt;: the neuron's input sum &lt;em&gt;before&lt;/em&gt; it produces its output.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w_i&lt;/code&gt;: the weight we want to adjust.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read the equation left to right as a story: "How much does the loss change if I nudge this weight?" = "how much the loss changes with the neuron's output" × "how much the output changes with its input sum" × "how much the input sum changes with the weight." Three gear ratios multiplied together. Do this for every weight in every layer and you get the &lt;strong&gt;gradient&lt;/strong&gt;: a complete to-do list of nudges that reduce the error.&lt;/p&gt;

&lt;p&gt;For the first time, a multi-layer network had a principled way to learn: not just the output layer, but &lt;em&gt;every&lt;/em&gt; layer, including the ones far from the reward.&lt;/p&gt;

&lt;h3&gt;
  
  
  Werbos's bigger vision: backprop as a tool for Bellman
&lt;/h3&gt;

&lt;p&gt;Here's the part that matters for this series. Werbos didn't think of backprop as just "neural network training." He saw it as a way to make &lt;strong&gt;Bellman's equations&lt;/strong&gt; usable on real problems. Remember from Blog 3: Bellman's math is perfect but chokes on large problems because you'd need a giant table with an entry for every possible situation. Werbos's idea: don't store the table, &lt;em&gt;approximate&lt;/em&gt; it with a neural network and train that network with backprop. He called this framework &lt;strong&gt;Adaptive Dynamic Programming&lt;/strong&gt; (ADP).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcf7ynuiimqzv2mjqcpcd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcf7ynuiimqzv2mjqcpcd.png" alt="BE + BACKPROP" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That exact idea (a neural network standing in for a value table) is what DeepMind used in DQN in 2013, thirty-nine years after Werbos's thesis (Blog 11). He saw the destination early; the hardware and data took decades to catch up.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pause and check.&lt;/strong&gt; Backprop answers "how much is each weight to blame?" ADP asks "what should we be using backprop &lt;em&gt;on&lt;/em&gt;?" The answer: an estimate of how good each situation is. That estimate has a name, and it's next.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Adaptive Dynamic Programming: wiring it all together
&lt;/h2&gt;

&lt;p&gt;We need one new idea before this makes sense: the &lt;strong&gt;value function&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;value&lt;/strong&gt; is a number answering "how good is this situation &lt;em&gt;in the long run&lt;/em&gt;?", not just "how good does it feel right now?"&lt;/p&gt;

&lt;p&gt;Back to cookies: imagine you've already added the salt disaster and the dough is mixed. Nothing bad has &lt;em&gt;happened&lt;/em&gt; yet. No reward, no punishment. But that dough is already doomed. A good value function would score it low &lt;em&gt;immediately&lt;/em&gt;, before anyone tastes it. That's the power of values: they let you judge a situation before the consequences show up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;high-value state&lt;/strong&gt; is one where, even with no immediate reward, the future looks rich.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;low-value state&lt;/strong&gt; is a trap: maybe it feels fine now, but it funnels you toward failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Bellman equation says how values relate to each other:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtmdorfnws73zurobzr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtmdorfnws73zurobzr0.png" alt="formula" width="680" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In words: &lt;em&gt;the value of a situation = the best action's (immediate reward + discounted value of wherever you land next).&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;V(s)&lt;/code&gt;: value of situation (state) &lt;code&gt;s&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt;: an action you could take. &lt;code&gt;max&lt;/code&gt; means "pick the best one."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;R(s,a)&lt;/code&gt;: the immediate reward.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;γ&lt;/code&gt; (gamma): a discount between 0 and 1. A reward tomorrow is worth a bit less than a reward today.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;P(s' | s, a)&lt;/code&gt;: the probability of landing in the next state &lt;code&gt;s'&lt;/code&gt;, and &lt;code&gt;V(s')&lt;/code&gt; is &lt;em&gt;its&lt;/em&gt; value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The catch, as always: you can't write a table for every state of a real problem. This is the &lt;strong&gt;curse of dimensionality&lt;/strong&gt;: the number of states explodes as problems grow. ADP's workaround is to use a neural network &lt;code&gt;V(s; weights)&lt;/code&gt; as a &lt;em&gt;stand-in&lt;/em&gt; for the table, and train it with backprop. The curse isn't gone, but it stops being a wall and becomes a negotiation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpf63hxv7ux6uxu9sbx9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpf63hxv7ux6uxu9sbx9u.png" alt="VALUE FUNCTION VISUALIZE" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Actor-Critic idea
&lt;/h3&gt;

&lt;p&gt;Out of ADP came one of the cleanest architectural ideas in all of RL, and it's still everywhere: &lt;strong&gt;Actor-Critic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmp44h4rc53h37f4scrd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmp44h4rc53h37f4scrd8.png" alt="Actor critique" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Actor&lt;/strong&gt; decides what to do. It tries things, explores, proposes moves. This is Klopf's trial-and-error learner.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Critic&lt;/strong&gt; judges how good the situation is, using a value function trained with backprop. This is Werbos's contribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An everyday analogy: a &lt;strong&gt;student (Actor)&lt;/strong&gt; writes essays, and a &lt;strong&gt;coach (Critic)&lt;/strong&gt; reads them. The coach doesn't write anything but learns to predict how good an essay will be. The student improves by listening to the coach's feedback, not just waiting for a final grade at the end of term. Meanwhile the coach also improves by comparing predictions to actual results. Both learn at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb6szc89x77hzbft8lmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb6szc89x77hzbft8lmf.png" alt="actor-critique" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And notice how the pieces line up: the Critic's prediction is the "expectation" in Klopf's update rule. When reality beats the Critic's prediction, that surprise tells the Actor "do more of that."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A quick date check so nothing here gets overstated.&lt;/strong&gt; ADP was being developed in the late 1970s (Werbos's early forms of it date to around 1977). The &lt;em&gt;actor-critic architecture as a working, tested system&lt;/em&gt; came in 1983, when Barto, Sutton and Anderson used it to learn pole balancing, which is the subject of Blog 7.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The big conceptual change: before this, learners mostly &lt;em&gt;reacted&lt;/em&gt;. With a value function they could &lt;em&gt;anticipate&lt;/em&gt;. A system balancing a pole can learn that a certain tilt is "bad news" before it falls. That's the difference between reflex and planning.&lt;/p&gt;




&lt;h2&gt;
  
  
  Stephen Grossberg: the warning label (1976)
&lt;/h2&gt;

&lt;p&gt;We now have a learner with drive, direction, and anticipation. Stephen Grossberg raised a problem that sounds almost boring but turned out to be one of the hardest in the field: &lt;strong&gt;learning can destroy what you already know.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Train a network hard on chess, then train it on Go, and it may forget chess, not gradually but catastrophically. New updates overwrite old structure. (The name &lt;strong&gt;catastrophic forgetting&lt;/strong&gt; was attached to this in the late 1980s, but Grossberg was already wrestling with the underlying issue in the 1970s.)&lt;/p&gt;

&lt;p&gt;An everyday version: you spend a year learning Spanish, then cram Italian for two months, and suddenly your Spanish is full of Italian words. Your brain used the same "shelf space" for both.&lt;/p&gt;

&lt;p&gt;Grossberg's &lt;strong&gt;Adaptive Resonance Theory (ART)&lt;/strong&gt;, from 1976, framed this as a tug-of-war between two forces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Plasticity:&lt;/strong&gt; the ability to learn new things.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stability:&lt;/strong&gt; the ability to keep what you already know.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Too much plasticity and you forget everything. Too much stability and you can never learn anything new. ART's answer: when a new input &lt;em&gt;resembles&lt;/em&gt; something you already know, the two "resonate" and the memory is updated. When it's &lt;em&gt;very different&lt;/em&gt;, don't overwrite, create a new category instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ln9z7st3wzfc47ubuy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ln9z7st3wzfc47ubuy3.png" alt="Plasticity VS Stability" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tension never went away. Continual learning, fine-tuning without forgetting, and knowledge distillation are all modern attempts at the problem Grossberg named in the 1970s.&lt;/p&gt;




&lt;h2&gt;
  
  
  Putting it together: desire, direction, memory
&lt;/h2&gt;

&lt;p&gt;Step back. By 1980 three ideas were on the table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Person&lt;/th&gt;
&lt;th&gt;Gave learning systems&lt;/th&gt;
&lt;th&gt;The key idea in one line&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Klopf&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;drive&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Learn from the gap between expected and actual reward; use a fading trace to know what to credit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Werbos&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;direction&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Send blame backward through layers with the chain rule; use it to train value estimates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Grossberg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A &lt;em&gt;memory&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Balance new learning against keeping old knowledge&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Learning Automata had none of the three. And remember our cookie problem? Klopf's trace says &lt;em&gt;which recent actions are eligible&lt;/em&gt;. Werbos's backprop says &lt;em&gt;how to push the blame back through the whole recipe&lt;/em&gt;. The value function says &lt;em&gt;this dough is doomed before anyone tastes it&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The scale was tiny by modern standards: a handful of neurons, small simulations, and a thesis that sat mostly unread. But the logic was complete.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this still matters today
&lt;/h3&gt;

&lt;p&gt;Here's a connection that makes this history feel less like a museum visit. Modern &lt;strong&gt;RLHF&lt;/strong&gt; (reinforcement learning from human feedback), the process used to tune chatbots like the one you may be chatting with, follows the same blueprint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;reward signal&lt;/em&gt; encodes what people prefer (helpful, correct, safe). That's Klopf's pleasure.&lt;/li&gt;
&lt;li&gt;When an output beats expectations, the pathways behind it get reinforced, and the blame or credit travels back through billions of weights via backprop. That's Werbos.&lt;/li&gt;
&lt;li&gt;The algorithm commonly used for this, &lt;strong&gt;PPO&lt;/strong&gt;, is an actor-critic method: one part proposes, another part estimates value. That's the architecture from this post.&lt;/li&gt;
&lt;li&gt;Keeping the model from forgetting how to do everything else while it's being tuned? That's Grossberg's problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The math is more sophisticated and the networks are enormous. But the skeleton hasn't changed. What evolved over five decades wasn't the idea. It was the scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;The pieces are on the table, but they're not assembled yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Klopf's biological intuitions need a rigorous mathematical home.&lt;/li&gt;
&lt;li&gt;Backprop needs to be tied explicitly to &lt;em&gt;temporal&lt;/em&gt; credit assignment (credit across time).&lt;/li&gt;
&lt;li&gt;Actor-Critic needs someone to build it, test it, and write it down properly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In 1981, Richard Sutton and Andrew Barto began doing exactly that, starting from a model of classical conditioning (think Pavlov's dog). Within a few years they'd produce the first rigorous treatment of temporal credit assignment in RL, including that pole-balancing actor-critic. That's when the field stopped being a collection of brilliant isolated ideas and started becoming a coherent science.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Next: Blog 7, The Sutton and Barto Foundation: Formalizing Temporal Credit Assignment (1981–1984).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>RL 5: Learning Automata and stochastic environments (1961–1974)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 03 Oct 2026 04:48:09 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-5-learning-automata-and-stochastic-environments-1961-1974-2m96</link>
      <guid>https://dev.to/mitanshgor/rl-5-learning-automata-and-stochastic-environments-1961-1974-2m96</guid>
      <description>&lt;p&gt;&lt;em&gt;Quick recap, in case you're jumping in from Blog 4.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Arthur Samuel's checkers program learned by &lt;strong&gt;guessing how good a board position was&lt;/strong&gt; (value estimation). Donald Michie's matchbox machine, MENACE, learned by &lt;strong&gt;shifting which move it preferred&lt;/strong&gt; (policy selection). Both worked. Both were fragile: Samuel needed hand-crafted features, and Michie needed one matchbox for every possible board.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That left a question hanging: &lt;strong&gt;what is the absolute minimum a machine needs in order to improve from feedback?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The first clean answer came from Moscow.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Before we start: a 60-second jargon cheat sheet
&lt;/h2&gt;

&lt;p&gt;You'll see these words a lot in this post. None of them are scary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent&lt;/strong&gt;: the thing that acts and learns (here, a tiny machine).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment&lt;/strong&gt;: whatever the agent interacts with (here, a set of slot machines).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action&lt;/strong&gt;: a choice the agent can make (which machine to pull).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reward / Penalty&lt;/strong&gt;: the feedback after an action. Good outcome = reward, bad outcome = penalty.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stochastic&lt;/strong&gt;: "random-ish." The same action can give different results on different tries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automaton&lt;/strong&gt; (plural: &lt;em&gt;automata&lt;/em&gt;): a machine that lives in one of a fixed number of &lt;em&gt;states&lt;/em&gt; and hops between them by simple rules. Think of a traffic light, not a supercomputer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State&lt;/strong&gt;: which "mode" the machine is currently in. Its memory, basically.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmr14p0dagnoyj6hrk9qt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmr14p0dagnoyj6hrk9qt.png" alt="one-glance glossary card" width="799" height="341"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 1: The smallest learning machines
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The problem: how do you learn when feedback is unreliable?
&lt;/h3&gt;

&lt;p&gt;Samuel and Michie taught us that machines &lt;em&gt;can&lt;/em&gt; learn from experience. But both of their systems quietly assumed the feedback made sense. Win the game, good. Lose the game, bad.&lt;/p&gt;

&lt;p&gt;Real life is messier. Picture vending machines on your street:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Machine A gives you a free snack &lt;strong&gt;70%&lt;/strong&gt; of the time.&lt;/li&gt;
&lt;li&gt;Machine B gives you a free snack &lt;strong&gt;40%&lt;/strong&gt; of the time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't know these numbers. You can only try a machine, see if it pays, and adjust. And here's the catch: Machine A will sometimes fail you, and Machine B will sometimes get lucky. One result tells you almost nothing.&lt;/p&gt;

&lt;p&gt;So the real question becomes: &lt;em&gt;how does a machine learn the right choice when any single outcome might be a lie?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's the world of &lt;strong&gt;stochastic environments&lt;/strong&gt;, and it's where Mikhail Tsetlin starts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9797ewqvbuw5tvxdiube.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9797ewqvbuw5tvxdiube.png" alt="slot machine octopus" width="298" height="247"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Meet Mikhail Tsetlin: the "smallest possible brain" guy
&lt;/h3&gt;

&lt;p&gt;Mikhail Tsetlin (1924–1966) was a Soviet mathematician working in Moscow in the era of early cybernetics. In 1961 he published a paper titled &lt;em&gt;"&lt;a href="https://www.mathnet.ru/php/archive.phtml?wshow=paper&amp;amp;jrnid=at&amp;amp;paperid=12417&amp;amp;option_lang=eng" rel="noopener noreferrer"&gt;On the behaviour of finite automata in random medium&lt;/a&gt;"&lt;/em&gt;. The title is a mouthful, but the idea is beautifully modest.&lt;/p&gt;

&lt;p&gt;Most researchers of the day asked, &lt;em&gt;"how do we build a smarter machine?"&lt;/em&gt; Tsetlin asked the opposite question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What is the &lt;em&gt;smallest&lt;/em&gt; internal structure a machine needs to improve its behavior?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not the most powerful. The smallest. He was hunting for the floor of machine intelligence.&lt;/p&gt;

&lt;p&gt;His answer was a &lt;strong&gt;finite-state automaton with a twist&lt;/strong&gt;: no model of the world, no predictions, no calculus, no score. Just:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a handful of internal states (its memory),&lt;/li&gt;
&lt;li&gt;a rule for choosing an action based on the current state, and&lt;/li&gt;
&lt;li&gt;a rule for moving between states based on feedback.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note the phrase &lt;strong&gt;"random medium"&lt;/strong&gt; in the title. That's Tsetlin's name for a stochastic environment: a world that answers your actions with reward or penalty according to hidden probabilities. The vending machines are a random medium.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Rooms: Tsetlin's memory, made visible
&lt;/h3&gt;

&lt;p&gt;The best way to understand a Tsetlin automaton is to picture a hallway of rooms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;left half&lt;/strong&gt; of the hallway is "Action A" (pull machine A).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;right half&lt;/strong&gt; is "Action B" (pull machine B).&lt;/li&gt;
&lt;li&gt;The machine is always standing in &lt;strong&gt;exactly one room&lt;/strong&gt;, and whatever side it's on decides what it does next.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a small version with 3 rooms per side (6 states total):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Action A side              Action B side
 [ 1 ] [ 2 ] [ 3 ] | [ 4 ] [ 5 ] [ 6 ]
  deep        edge  |  edge        deep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The rules are only two lines long:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reward&lt;/strong&gt; -&amp;gt; walk &lt;em&gt;deeper&lt;/em&gt; into your current side (more committed).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Penalty&lt;/strong&gt; -&amp;gt; walk one room &lt;em&gt;toward the middle&lt;/em&gt;. If you were already at the edge, you cross the border and switch actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback is just a single bit: &lt;code&gt;0&lt;/code&gt; = reward, &lt;code&gt;1&lt;/code&gt; = penalty. No scores, no probabilities, no gradients. Only movement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flzj9ymwvpnb95160k3s5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flzj9ymwvpnb95160k3s5.png" alt="the 6-room hallway diagram" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Let's walk through it
&lt;/h4&gt;

&lt;p&gt;Say we start in room 3 (the edge of Action A) and keep pulling machine A, which pays 70% of the time:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Room&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Where we go next&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 2 (deeper)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 1 (deepest)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Penalty&lt;/strong&gt; (bad luck!)&lt;/td&gt;
&lt;td&gt;Room 2 (one step back)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Reward&lt;/td&gt;
&lt;td&gt;Room 1 again&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Look at step 3. The machine got unlucky, but it didn't panic. One bad result only moved it one room, and it was still firmly on Team A. The rooms &lt;em&gt;absorbed&lt;/em&gt; the noise.&lt;/p&gt;


&lt;h3&gt;
  
  
  Why memory matters (why not just flip a coin?)
&lt;/h3&gt;

&lt;p&gt;You might ask: if feedback is just reward/penalty, why bother with six rooms? Why not the simplest rule ever: &lt;em&gt;"if it paid, do it again; if not, switch"&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Funny thing: that rule &lt;em&gt;is&lt;/em&gt; a Tsetlin automaton, the smallest one, with only &lt;strong&gt;1 room per side&lt;/strong&gt;. It's the classic &lt;strong&gt;win-stay, lose-shift&lt;/strong&gt; strategy. And it's jumpy. One unlucky penalty and it abandons a perfectly good machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbxgjkrd8zoavir5owxnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbxgjkrd8zoavir5owxnb.png" alt="favorite restaurant" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Think of your favorite restaurant. You had one bad meal. Do you never go back? Of course not. You have &lt;em&gt;memory&lt;/em&gt; of many good meals, so one bad night doesn't flip your opinion. More rooms = more patience.&lt;/p&gt;

&lt;p&gt;So let's test it. I simulated the exact hallway above (Machine A pays 70%, Machine B pays 40%, 5,000 pulls per run, averaged over 200 runs), changing only the number of rooms per side, &lt;code&gt;N&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rooms per side (N)&lt;/th&gt;
&lt;th&gt;Share of pulls on the better machine&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 (win-stay, lose-shift)&lt;/td&gt;
&lt;td&gt;~67%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;~80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;~89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;~97.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;~99.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;More memory, better decisions. Here's the tiny code if you want to try it yourself:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# states 1..N   -&amp;gt; action 0 (1 = deepest, N = edge)
&lt;/span&gt;    &lt;span class="c1"&gt;# states N+1..2N -&amp;gt; action 1 (N+1 = edge, 2N = deepest)
&lt;/span&gt;    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;
    &lt;span class="n"&gt;pulls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;pulls&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;pay&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rewarded&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;pulls&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;tsetlin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggehdderk70yuazbqcas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fggehdderk70yuazbqcas.png" alt="linechart" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tsetlin proved this trend mathematically. As &lt;code&gt;N&lt;/code&gt; grows, the automaton gets arbitrarily close to always picking the best action:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;best&amp;nbsp;action&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;→&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;→&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∞&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;Two honest footnotes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This works when the best action really is better than a coin flip (its penalty probability is below 50%). Our 70% machine qualifies.&lt;/li&gt;
&lt;li&gt;Memory has a price. A deep automaton is stubborn: if the world &lt;em&gt;changes&lt;/em&gt; (say, Machine B suddenly gets better), a machine sitting in the deepest room needs many penalties to walk out. &lt;strong&gt;Stability and adaptability pull in opposite directions.&lt;/strong&gt; Remember this tension; it comes back in Part 2.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  The catch: rooms don't scale
&lt;/h3&gt;

&lt;p&gt;Tsetlin's automaton is elegant, but notice what it needs: a &lt;strong&gt;hand-designed hallway&lt;/strong&gt;. How many rooms? Which transitions? For two actions it's easy. For a hundred actions you'd be designing a giant state machine by hand.&lt;/p&gt;

&lt;p&gt;It's the same flavor of problem we hit in Blog 4: &lt;strong&gt;Michie needed a matchbox per board.&lt;/strong&gt; Tsetlin needed a room per memory level. Someone had to ask: &lt;em&gt;what if we just delete the rooms?&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Delete the rooms: Variable-Structure Automata
&lt;/h3&gt;

&lt;p&gt;The idea of replacing rooms with probabilities dates to Soviet researchers &lt;strong&gt;Varshavskii and Vorontsova (1963)&lt;/strong&gt;, and similar update rules were being explored in mathematical psychology around the same time. Then in &lt;strong&gt;1974&lt;/strong&gt;, &lt;strong&gt;Kumpati Narendra and M. A. L. Thathachar&lt;/strong&gt; published a landmark survey, &lt;em&gt;"Learning Automata: A Survey"&lt;/em&gt;, that organized the whole field, gave it its name in the West, and split it into two families:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Fixed-Structure Automata (FSA): Tsetlin's world.&lt;/strong&gt;&lt;br&gt;
The hallway is fixed. Learning = &lt;em&gt;moving through rooms&lt;/em&gt;. Where you go next depends only on where you are now and whether you were just rewarded or penalized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuxiu5rlp1a0fg7rlhwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuxiu5rlp1a0fg7rlhwz.png" alt="transition matrix" width="774" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Variable-Structure Automata (VSA): throw away the house.&lt;/strong&gt;&lt;br&gt;
No rooms at all. Instead the machine keeps a &lt;strong&gt;list of probabilities&lt;/strong&gt;, one per action, that always adds up to 100%. Like a set of volume knobs where turning one up turns the others down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9br0bbgjdjan774w8bbq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9br0bbgjdjan774w8bbq.png" alt="state themselves were unnecessary" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learning becomes: &lt;em&gt;"that worked, so turn its knob up a bit."&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  The volume-knob rule, with real numbers
&lt;/h4&gt;

&lt;p&gt;Let &lt;code&gt;p_i&lt;/code&gt; be the probability of picking action &lt;code&gt;i&lt;/code&gt;, and &lt;code&gt;λ&lt;/code&gt; (lambda) a small "step size" called the &lt;strong&gt;learning rate&lt;/strong&gt;. When the chosen action &lt;code&gt;i&lt;/code&gt; is &lt;strong&gt;rewarded&lt;/strong&gt;:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;and every &lt;em&gt;other&lt;/em&gt; action &lt;code&gt;j&lt;/code&gt; is nudged down so the total stays at 1:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Concrete example with 3 actions, &lt;code&gt;p = [0.50, 0.30, 0.20]&lt;/code&gt;, &lt;code&gt;λ = 0.1&lt;/code&gt;, and action 1 gets rewarded:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Action 1: 0.50 + 0.1 x (1 - 0.50) = &lt;strong&gt;0.55&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Action 2: 0.30 x 0.9 = &lt;strong&gt;0.27&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Action 3: 0.20 x 0.9 = &lt;strong&gt;0.18&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;New total: 0.55 + 0.27 + 0.18 = &lt;strong&gt;1.00&lt;/strong&gt; ✓&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the same action is &lt;strong&gt;penalized&lt;/strong&gt; instead, the mirror-image rule turns its knob &lt;em&gt;down&lt;/em&gt; and spreads that probability over the others:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;r&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;p&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;j&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;(&lt;code&gt;r&lt;/code&gt; is the number of actions.) With our example: action 1 drops to &lt;strong&gt;0.45&lt;/strong&gt;, action 2 rises to &lt;strong&gt;0.32&lt;/strong&gt;, action 3 to &lt;strong&gt;0.23&lt;/strong&gt;. Still totals 1.&lt;/p&gt;

&lt;p&gt;Notice something? &lt;strong&gt;No rooms, no transition table, no memory hallway.&lt;/strong&gt; The probability list &lt;em&gt;is&lt;/em&gt; the memory. One small rule replaced a whole state machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq88aesd7irzmubuvmx7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq88aesd7irzmubuvmx7h.png" alt="idea cleanly" width="794" height="104"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Why this matters for modern RL
&lt;/h3&gt;

&lt;p&gt;This is where the old Soviet-era ideas quietly show up in today's algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Raise the probability of what worked" is the heart of policy gradient methods&lt;/strong&gt; (we'll get there properly in Blog 10). Ronald Williams's &lt;strong&gt;REINFORCE&lt;/strong&gt; algorithm (1992) is a direct descendant, and Williams himself showed that a learning automaton can be viewed as a special case of REINFORCE. It's the volume knob again, just dressed up with gradients so it can tune millions of parameters instead of three numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tsetlin's rooms have a living descendant too.&lt;/strong&gt; In 2018, Ole-Christoffer Granmo introduced the &lt;strong&gt;Tsetlin Machine&lt;/strong&gt;, which uses teams of Tsetlin automata to learn human-readable logic rules from data. It's a rare case of a 1961 idea being revived as a modern machine-learning method, notable for being interpretable and cheap to run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And the same tension keeps returning.&lt;/strong&gt; Tsetlin's "memory = stability, but also stubbornness" is the modern stability-vs-adaptability problem that every RL practitioner still wrestles with.&lt;/p&gt;




&lt;h3&gt;
  
  
  Tsetlin vs. Narendra: two halves of one answer
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Tsetlin (rooms)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Variable-structure (volume knobs)&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory lives in...&lt;/td&gt;
&lt;td&gt;Which room you're in&lt;/td&gt;
&lt;td&gt;The probability list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strength&lt;/td&gt;
&lt;td&gt;Stable; noise gets absorbed&lt;/td&gt;
&lt;td&gt;Simple; scales to many actions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weakness&lt;/td&gt;
&lt;td&gt;Architecture must be designed by hand&lt;/td&gt;
&lt;td&gt;Needs a careful step size &lt;code&gt;λ&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answers the question&lt;/td&gt;
&lt;td&gt;&lt;em&gt;"Where do I go next?"&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;"How much do I like this action now?"&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern echo&lt;/td&gt;
&lt;td&gt;Tsetlin Machines, stability vs. adaptability&lt;/td&gt;
&lt;td&gt;Policy gradients, REINFORCE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Together they gave the field its first solid answer to Tsetlin's question: a machine can improve from nothing but feedback, with no model of the world.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2: The puzzle behind it all, the Multi-Armed Bandit
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Zoom out: you've been solving a famous problem
&lt;/h3&gt;

&lt;p&gt;What you just saw, a row of slot machines with unknown payouts and a limited number of pulls, is famously called the &lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Multi-armed_bandit" rel="noopener noreferrer"&gt;Multi-Armed Bandit&lt;/a&gt;&lt;/strong&gt; problem ("one-armed bandit" is old slang for a slot machine). The idea goes back to &lt;strong&gt;Thompson (1933)&lt;/strong&gt;, who asked how to split patients between two treatments, and the statistician &lt;a href="https://en.wikipedia.org/wiki/Herbert_Robbins" rel="noopener noreferrer"&gt;Herbert Robbins&lt;/a&gt; formalized it in 1952. Tsetlin's random-medium experiments attacked the same core dilemma from an automata angle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftd8ohegnsebujhhkfyfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftd8ohegnsebujhhkfyfx.png" alt="Herbert_Robbins" width="203" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is the cleanest version of the &lt;strong&gt;exploration vs. exploitation&lt;/strong&gt; trade-off we met in Blog 4 with Samuel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exploit&lt;/strong&gt;: keep pulling the machine that seems best.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore&lt;/strong&gt;: try another one, in case it's actually better.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interesting detail: a Tsetlin automaton never &lt;em&gt;decides&lt;/em&gt; to explore. Noise does it for it. Occasional penalties push it toward the boundary, and it sometimes tries the other side. Exploration falls out of the structure for free.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvprbvuj8i4azn2i60ik6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvprbvuj8i4azn2i60ik6.png" alt="bandit diagram: 3 slot machines" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rooms and volume knobs are two ways to play this game. Engineers have since built sharper ones. To compare them fairly, we first need to state the problem cleanly.&lt;/p&gt;

&lt;h4&gt;
  
  
  The setup
&lt;/h4&gt;

&lt;p&gt;You face &lt;code&gt;K&lt;/code&gt; machines (called &lt;strong&gt;arms&lt;/strong&gt;). Arm &lt;code&gt;a&lt;/code&gt; pays out according to some fixed, &lt;strong&gt;unknown&lt;/strong&gt; average &lt;code&gt;μ_a&lt;/code&gt;. At every step &lt;code&gt;t = 1, 2, ..., T&lt;/code&gt; you pick one arm and see the reward from &lt;em&gt;that arm only&lt;/em&gt;. Your goal: collect as much total reward as possible over &lt;code&gt;T&lt;/code&gt; steps.&lt;/p&gt;

&lt;p&gt;Two things make this hard:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You only see the arm you pulled.&lt;/strong&gt; You never learn what the other arms &lt;em&gt;would&lt;/em&gt; have paid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your data depends on your choices.&lt;/strong&gt; If you stop pulling an arm, you stop learning about it. A bad first impression can become permanent.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Scored, not taught
&lt;/h4&gt;

&lt;p&gt;Compare this to supervised learning, where a teacher hands the machine the right answer ("this image is a cat"). A bandit gets no such answer. It only gets a &lt;em&gt;score&lt;/em&gt; for what it did ("that ad got a click") and no hint about whether something else would have scored higher. The only way to find out is to try other things. Sutton and Barto call this &lt;strong&gt;evaluative feedback&lt;/strong&gt;, and it's the reason exploration exists at all.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why bandits matter
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;They isolate exploration vs. exploitation.&lt;/strong&gt; One situation, no delayed consequences, so you can study the dilemma in its purest form.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They score you &lt;em&gt;while&lt;/em&gt; you learn.&lt;/strong&gt; Not "how accurate is the model after training," but "how much did you lose along the way." That score is called &lt;strong&gt;regret&lt;/strong&gt;, coming up next.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  A few new words
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arm&lt;/strong&gt;: one choice you can make (a slot machine, an ad, a headline).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Q(a)&lt;/strong&gt;: your &lt;em&gt;running estimate&lt;/em&gt; of how good arm &lt;code&gt;a&lt;/code&gt; is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gap (Δ)&lt;/strong&gt;: how much worse an arm is than the best arm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regret&lt;/strong&gt;: the total reward you &lt;em&gt;lost&lt;/em&gt; by not always playing the best arm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Posterior&lt;/strong&gt;: your belief about an arm's true payout after seeing data. Wide = unsure. Narrow = confident.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Two tools you need: estimating and keeping score
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Estimating an arm's value, one pull at a time
&lt;/h4&gt;

&lt;p&gt;After &lt;code&gt;n&lt;/code&gt; pulls of an arm, the average reward is &lt;code&gt;Q_n = (R_1 + R_2 + ... + R_n) / n&lt;/code&gt;. You never need to store the history. Rearranging gives an update that shows up &lt;em&gt;everywhere&lt;/em&gt; in RL:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In words: &lt;strong&gt;new estimate = old estimate + step size x (target - old estimate)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now swap the &lt;code&gt;1/n&lt;/code&gt; for a constant &lt;code&gt;α&lt;/code&gt;. Old rewards fade out gradually, so you track a &lt;em&gt;moving&lt;/em&gt; target instead of a fixed one. That's how you cope with a world that changes (we'll see the payoff in the practical section).&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Remember the volume knob?&lt;/strong&gt; The reward rule &lt;code&gt;p ← p + λ(1 - p)&lt;/code&gt; from earlier is this exact update with target &lt;code&gt;1&lt;/code&gt;. Same idea, different clothes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Regret: the scoreboard
&lt;/h4&gt;

&lt;p&gt;Let &lt;code&gt;μ*&lt;/code&gt; be the average payout of the best arm and &lt;code&gt;Δ_a = μ* - μ_a&lt;/code&gt; the gap of arm &lt;code&gt;a&lt;/code&gt;. After &lt;code&gt;T&lt;/code&gt; steps, the &lt;strong&gt;regret&lt;/strong&gt; is how much you earned &lt;em&gt;less&lt;/em&gt; than someone who knew the best arm from the start:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathcal"&gt;R&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;μ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mbin mtight"&gt;∗&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mrel mtight"&gt;:&lt;/span&gt;&lt;span class="mspace mtight"&gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mrel mtight"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathbb"&gt;E&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;(&lt;code&gt;E[...]&lt;/code&gt; just means "on average," and &lt;code&gt;N_T(a)&lt;/code&gt; is how many times you pulled arm &lt;code&gt;a&lt;/code&gt;.) The second form is the useful one: &lt;strong&gt;regret = (cost per bad pull) x (number of bad pulls).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Quick example with our vending machines: the gap between A (70%) and B (40%) is 0.3. Every pull of B costs you 0.3 snacks on average, so 100 pulls of B means about 30 snacks of regret. To keep regret low you must pull bad arms as rarely as possible, but you can't skip them entirely, or you'd never know they were bad.&lt;/p&gt;

&lt;p&gt;How should regret grow over time?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linear in &lt;code&gt;T&lt;/code&gt;&lt;/strong&gt;: you never stopped making mistakes. Failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logarithmic in &lt;code&gt;T&lt;/code&gt;&lt;/strong&gt;: mistakes become rarer and rarer, so regret grows slower and slower. This is the best anyone can do, which Lai and Robbins proved in 1985.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more intuition worth keeping: &lt;strong&gt;the closer two options are, the longer it takes to tell them apart&lt;/strong&gt;, and the more exploring you must pay for. Telling a 70% machine from a 40% one is easy. Telling 12% from 15% takes thousands of pulls.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5t1ezrftyg0hb6tdj8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw5t1ezrftyg0hb6tdj8r.png" alt="regret curve chart" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  The strategy zoo
&lt;/h3&gt;

&lt;p&gt;Now the fun part. We'll go through the main strategies, each with its rule, its intuition, its math, and where it breaks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fduxitkjcemeun9kn432b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fduxitkjcemeun9kn432b.png" alt="strategy zoo" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Greedy: always pick the best-looking arm
&lt;/h4&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Simple, and &lt;strong&gt;broken&lt;/strong&gt;. A single lucky early pull on a mediocre arm can make its estimate look best, and since pure greedy never samples anything else, it locks onto that arm forever. That's &lt;strong&gt;linear regret&lt;/strong&gt;, caused by zero exploration.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. ε-greedy: add some randomness
&lt;/h4&gt;

&lt;p&gt;With probability &lt;code&gt;1 - ε&lt;/code&gt; pick the best-looking arm; with probability &lt;code&gt;ε&lt;/code&gt; pick uniformly at random. Dead simple and a great baseline.&lt;/p&gt;

&lt;p&gt;Its flaw is mathematical: random exploration continues forever, even when you're certain. Because &lt;code&gt;ε&lt;/code&gt; stays fixed (say, &lt;code&gt;0.10&lt;/code&gt;), each arm is chosen with probability at least &lt;code&gt;ε/K&lt;/code&gt; at every step, which gives:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathcal"&gt;R&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≥&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;ϵ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size2"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;That's &lt;strong&gt;linear regret&lt;/strong&gt;. A fixed &lt;code&gt;ε&lt;/code&gt; is a permanent tax: even after 1,000,000 pulls, when you know exactly which arm is best, you still waste about 10% of pulls on random choices. (Shrinking &lt;code&gt;ε&lt;/code&gt; over time can fix this, but then you have a schedule to tune.)&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Optimistic initialization: let disappointment drive exploration
&lt;/h4&gt;

&lt;p&gt;Start every estimate absurdly high, for example &lt;code&gt;Q_1(a) = +5&lt;/code&gt; when real rewards range from 0 to 1. Every arm you try then "disappoints" compared to that starting hope, so the greedy rule naturally moves on to the untried arms. It's a clever, nearly free trick that gets a purely greedy algorithm to try everything without any random choices.&lt;/p&gt;

&lt;p&gt;The catch: once every arm has been sampled enough, the optimism is gone and the estimates settle at their true averages. If the world changes later (a bad machine suddenly starts paying well), the agent won't re-investigate, because that machine's estimate was pushed down long ago. It only drives exploration during the opening phase.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. UCB: optimism in the face of uncertainty
&lt;/h4&gt;

&lt;p&gt;UCB (Upper Confidence Bound) is the first strategy built on rigorous probability theory. Instead of picking the arm with the best &lt;em&gt;average&lt;/em&gt;, you pick the arm with the best &lt;strong&gt;plausible upper bound&lt;/strong&gt;: its estimate plus an &lt;strong&gt;uncertainty bonus&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;Q&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;c&lt;/span&gt;&lt;span class="mord sqrt"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span class="svg-align"&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop"&gt;ln&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="hide-tail"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;How the bonus behaves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It shrinks with experience.&lt;/strong&gt; The more you pull an arm (&lt;code&gt;N&lt;/code&gt; grows), the smaller its bonus, because its average is already trustworthy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It grows with time.&lt;/strong&gt; As &lt;code&gt;t&lt;/code&gt; ticks forward, the bonus creeps up for neglected arms, so every option eventually gets another look.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A worked example&lt;/strong&gt; (using &lt;code&gt;c = 1&lt;/code&gt; to keep things simple; at step &lt;code&gt;t = 200&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Average &lt;code&gt;Q&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Pulls &lt;code&gt;N&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Bonus&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Arm A&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;0.23&lt;/td&gt;
&lt;td&gt;0.73&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Arm B&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;0.73&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.13&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Arm A has the better average, but UCB plays &lt;strong&gt;Arm B&lt;/strong&gt;, because with only 10 pulls it might still be hiding something great. Pull B a few more times and its bonus shrinks; if its average stays low, A takes over again. Exploration shrinks exactly as fast as your doubt does.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Thompson Sampling: let each arm "vote" with a random draw
&lt;/h4&gt;

&lt;p&gt;Thompson's 1933 algorithm is surprisingly simple, and works remarkably well:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep a &lt;strong&gt;posterior&lt;/strong&gt; (a curve showing how confident you are about each arm's payout).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Draw one random sample&lt;/strong&gt; from each arm's curve.&lt;/li&gt;
&lt;li&gt;Play the arm whose sample is highest.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For yes/no outcomes (clicks vs. no clicks), the natural curve is the &lt;strong&gt;Beta distribution&lt;/strong&gt;. You start with a flat &lt;code&gt;Beta(1, 1)&lt;/code&gt; ("total uncertainty"). After &lt;code&gt;s&lt;/code&gt; successes and &lt;code&gt;f&lt;/code&gt; failures, it becomes &lt;code&gt;Beta(1 + s, 1 + f)&lt;/code&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Worked example
&lt;/h5&gt;

&lt;p&gt;Two ads show roughly the same 30% click rate, but with very different amounts of evidence:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Data&lt;/th&gt;
&lt;th&gt;Posterior&lt;/th&gt;
&lt;th&gt;Mean&lt;/th&gt;
&lt;th&gt;Std. Dev.&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ad X&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;3 clicks / 10 views&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Beta(4, 8)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0.333&lt;/td&gt;
&lt;td&gt;0.131&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ad Y&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;30 clicks / 100 views&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Beta(31, 71)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0.304&lt;/td&gt;
&lt;td&gt;0.045&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Similar averages, wildly different &lt;strong&gt;certainty&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmegnanrcuc0eonw8h1g3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmegnanrcuc0eonw8h1g3.gif" alt="Example Ads X and Y" width="720" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  How self-correcting exploration works
&lt;/h5&gt;

&lt;p&gt;Because &lt;strong&gt;Ad X&lt;/strong&gt; has a wide, uncertain curve, its random draws beat &lt;strong&gt;Ad Y&lt;/strong&gt;'s about &lt;strong&gt;58%&lt;/strong&gt; of the time. That balances exploring and exploiting automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exploitation (Ad Y):&lt;/strong&gt; a reliable performer with high confidence, a stable baseline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploration (Ad X):&lt;/strong&gt; unproven. It could turn out to be a weak ad or a game-changer, and the width of its curve is the potential upside of learning more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic feedback loop:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;If Ad X's future impressions fail to convert, its curve shifts left and narrows, so it loses future draws and drops out of rotation.&lt;/li&gt;
&lt;li&gt;If Ad X keeps converting, its curve narrows around a high mean and it becomes the new winner.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thompson Sampling spends exploration effort in proportion to uncertainty, with almost no tuning (no &lt;code&gt;c&lt;/code&gt;, no &lt;code&gt;ε&lt;/code&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Gradient bandits: learn preferences, not values
&lt;/h4&gt;

&lt;p&gt;Instead of estimating &lt;em&gt;how good&lt;/em&gt; each arm is, learn a numerical &lt;strong&gt;preference&lt;/strong&gt; &lt;code&gt;H(a)&lt;/code&gt; and turn preferences into probabilities with a softmax (a recipe that turns any list of numbers into probabilities that add up to 1):&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mop"&gt;&lt;span class="mop op-symbol small-op"&gt;∑&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;span class="mclose mtight"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;e&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen mtight"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mclose mtight"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;After pulling &lt;code&gt;A_t&lt;/code&gt; and receiving &lt;code&gt;R_t&lt;/code&gt;, update, using the running average reward &lt;code&gt;R̄_t&lt;/code&gt; as a &lt;strong&gt;baseline&lt;/strong&gt; ("what I normally get"):&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;ˉ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mopen"&gt;[&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;A&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;]&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In plain words: &lt;strong&gt;better than usual? Push the chosen arm's preference up and the others down. Worse than usual? The reverse.&lt;/strong&gt; (Mathematically this is gradient ascent on average reward, and the baseline keeps the updates from being too jumpy.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9arle2i6pwew8llt78u9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9arle2i6pwew8llt78u9.gif" alt="softmax vs Thompson Sampling" width="760" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Back to Part 1, and a preview of Blog 10:&lt;/strong&gt; this is the volume-knob idea again ("raise the probability of what worked"), now with a gradient. Bandits are where policy gradients start.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Let's measure them
&lt;/h3&gt;

&lt;p&gt;Theory is nice. Here's what actually happens. I ran two experiments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment 1: the classic 10-armed testbed.&lt;/strong&gt; Each run draws 10 arm averages at random, rewards are noisy around those averages, 1,000 steps, averaged over 1,000 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Avg reward (last 200 steps)&lt;/th&gt;
&lt;th&gt;% pulls on best arm&lt;/th&gt;
&lt;th&gt;Cumulative regret @ 1,000&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Greedy (ε = 0)&lt;/td&gt;
&lt;td&gt;0.997&lt;/td&gt;
&lt;td&gt;34.7%&lt;/td&gt;
&lt;td&gt;508.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy, ε = 0.01&lt;/td&gt;
&lt;td&gt;1.345&lt;/td&gt;
&lt;td&gt;62.0%&lt;/td&gt;
&lt;td&gt;327.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy, ε = 0.1&lt;/td&gt;
&lt;td&gt;1.346&lt;/td&gt;
&lt;td&gt;79.4%&lt;/td&gt;
&lt;td&gt;229.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Optimistic init (Q₁ = 5, α = 0.1)&lt;/td&gt;
&lt;td&gt;1.499&lt;/td&gt;
&lt;td&gt;86.2%&lt;/td&gt;
&lt;td&gt;238.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gradient bandit (α = 0.1)&lt;/td&gt;
&lt;td&gt;1.495&lt;/td&gt;
&lt;td&gt;83.9%&lt;/td&gt;
&lt;td&gt;184.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UCB (c = 2)&lt;/td&gt;
&lt;td&gt;1.524&lt;/td&gt;
&lt;td&gt;85.9%&lt;/td&gt;
&lt;td&gt;147.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thompson sampling&lt;/td&gt;
&lt;td&gt;1.546&lt;/td&gt;
&lt;td&gt;90.3%&lt;/td&gt;
&lt;td&gt;68.4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okayvl2rtyyu1053c44.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1okayvl2rtyyu1053c44.gif" alt="Exp 1" width="799" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two honest footnotes: &lt;br&gt;
(1) Thompson's starting beliefs here &lt;em&gt;exactly match&lt;/em&gt; how the arms were generated, which flatters it, so don't expect a 2x regret win in the wild; &lt;br&gt;
(2) &lt;code&gt;c = 2&lt;/code&gt; uses the Sutton-Barto form &lt;code&gt;c·√(ln t / N)&lt;/code&gt;, and &lt;code&gt;c&lt;/code&gt; is a tuning knob.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experiment 2: how does regret &lt;em&gt;grow&lt;/em&gt;?&lt;/strong&gt; Five arms with success rates 0.10, 0.12, 0.15, 0.20, 0.25 (small gaps, like real conversion rates), averaged over 40 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Regret @ 1,000&lt;/th&gt;
&lt;th&gt;@ 5,000&lt;/th&gt;
&lt;th&gt;@ 20,000&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ε-greedy (ε = 0.1)&lt;/td&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;233&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UCB1 (c = √2)&lt;/td&gt;
&lt;td&gt;61&lt;/td&gt;
&lt;td&gt;204&lt;/td&gt;
&lt;td&gt;418&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thompson&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;57&lt;/td&gt;
&lt;td&gt;73&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read this one slowly, because it teaches something the textbooks gloss over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ε-greedy's regret grows at a constant slope&lt;/strong&gt; (about 0.0086 per step between 5k and 20k), matching the &lt;code&gt;(ε/K)ΣΔ&lt;/code&gt; floor we derived. It will lose in the long run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UCB1 is &lt;em&gt;worse&lt;/em&gt; than ε-greedy at this horizon.&lt;/strong&gt; Its "grows slower and slower" guarantee is real, but its constants are conservative, and its slope (about 0.014 per step here) is still shrinking. "Best in the long run" does not mean "best at your horizon."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thompson's slope is about 0.001 per step.&lt;/strong&gt; Nearly flat. That's why you see it so often in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpwa35hzmgkl1bcqad71.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpwa35hzmgkl1bcqad71.gif" alt="Experiment 2" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  A reference implementation
&lt;/h4&gt;

&lt;p&gt;Small enough to read in one sitting, tested to produce the numbers above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EpsGreedy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# alpha =&amp;gt; non-stationary
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UCB1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;                      &lt;span class="c1"&gt;# t starts at 1
&lt;/span&gt;        &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;argmin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# play every arm once first
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ThompsonBernoulli&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;K&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# Beta(1,1) prior
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;argmax&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;regret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;regret&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;probs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;regret&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ThompsonBernoulli&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  The practical corner: using a bandit for real
&lt;/h3&gt;

&lt;h4&gt;
  
  
  When a bandit is the right tool
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feedback is immediate.&lt;/strong&gt; You act, you get a number, and your action doesn't change what situations you'll face next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Showing the loser has a real cost.&lt;/strong&gt; Every user sent to a worse option is lost revenue, clicks, or goodwill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choices are discrete and few-ish.&lt;/strong&gt; Headlines, layouts, models, prompts, settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You'll keep running it.&lt;/strong&gt; A bandit is a &lt;em&gt;loop&lt;/em&gt;, not a one-off analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  when the world changes
&lt;/h4&gt;

&lt;p&gt;Five arms with success rates &lt;code&gt;0.2, 0.3, 0.4, 0.5, 0.7&lt;/code&gt; for 4,000 steps, and at step 2,000 the order is &lt;strong&gt;reversed&lt;/strong&gt;, so the best arm becomes the worst. Total reward, averaged over 500 runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Estimator&lt;/th&gt;
&lt;th&gt;Total reward&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Plain average (assumes the world never changes)&lt;/td&gt;
&lt;td&gt;~1,791&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Constant step size, &lt;code&gt;α = 0.1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;~2,560&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Only the last 500 observations ("sliding window")&lt;/td&gt;
&lt;td&gt;~2,537&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Someone who always knows the best arm&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;2,800&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The plain average never recovers: after 2,000 steps its estimates are so weighed down by history that new evidence barely moves them. Switching to a constant step size, a one-line change, won back about &lt;strong&gt;770 reward&lt;/strong&gt;. This is Tsetlin's stability-vs-adaptability tension again, now with a dial you control.&lt;/p&gt;

&lt;h4&gt;
  
  
  Choosing an algorithm
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;Reach for&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Clicks / conversions (yes or no), you want a strong default&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Thompson (Beta-Bernoulli)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Almost no tuning, strong in practice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need a deterministic, explainable rule&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;UCB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same inputs always give the same choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payouts drift over time&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Any of these with a constant step size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Old data fades&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Each decision comes with info about the user&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Contextual bandit&lt;/strong&gt; (a bandit that first looks at who's in front of it)&lt;/td&gt;
&lt;td&gt;Personalizes the choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You want something trivial to ship today&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;ε-greedy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Easiest to explain and debug&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Where it all runs out of road
&lt;/h3&gt;

&lt;p&gt;So, problem solved? Not quite. Learning automata and bandits share two big blind spots:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. They don't see the situation, and they don't change it.&lt;/strong&gt; The machine picks an action, but it never &lt;em&gt;observes&lt;/em&gt; anything about the world first. There's no "if the board looks like this, do that." A vending machine is always the same vending machine, and pulling its lever doesn't change what comes next. Real problems change from moment to moment: chess boards, road conditions, the words already written in a sentence. (If you only add the "look at the situation first" part, you get a &lt;em&gt;contextual bandit&lt;/em&gt;, which is a halfway house between bandits and full RL. If your actions also change the &lt;em&gt;next&lt;/em&gt; situation, you've left bandit territory entirely.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. They only understand immediate feedback.&lt;/strong&gt; Every update reacts to the reward &lt;em&gt;right now&lt;/em&gt; for the action &lt;em&gt;just taken&lt;/em&gt;. But in most interesting problems, consequences arrive late:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A chess move that quietly weakens your position may not cost you the game for 20 turns.&lt;/li&gt;
&lt;li&gt;A financial decision may not show its results for months.&lt;/li&gt;
&lt;li&gt;A word you choose early in a sentence shapes everything after it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The machine would have to guess &lt;em&gt;which&lt;/em&gt; of its past actions deserves the blame or credit. It has no mechanism for that. This is the famous &lt;strong&gt;credit assignment problem&lt;/strong&gt;, and it is the gap the next era of RL sets out to fill. (Samuel's checkers program from Blog 4 was already sniffing around this problem. Its temporal-difference trick gets its full moment later in the series.)&lt;/p&gt;




&lt;h3&gt;
  
  
  Quick recap
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Question:&lt;/strong&gt; what is the smallest structure that lets a machine improve from feedback?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tsetlin (1961):&lt;/strong&gt; a hallway of rooms. Reward = go deeper, penalty = step back. More rooms = more stability, but also more stubbornness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable-structure automata (1963-1974):&lt;/strong&gt; delete the rooms, keep a probability per action, and nudge it up or down with feedback. This is the seed of policy gradients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Both are ways of playing the multi-armed bandit&lt;/strong&gt;, the cleanest version of exploring vs. exploiting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regret&lt;/strong&gt; (reward lost vs. always playing the best arm) is the scoreboard. Linear = failing, logarithmic = best possible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The toolkit:&lt;/strong&gt; ε-greedy (simple, permanent exploration tax), UCB (optimism about what you haven't tried), Thompson sampling (explore in proportion to doubt, great in practice), gradient bandits (learn preferences, the cousin of policy gradients).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In practice:&lt;/strong&gt; a bandit beat a fixed A/B split by roughly 4x in lost conversions in our simulation, and a constant step size won back ~770 reward after the world flipped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blind spots:&lt;/strong&gt; no awareness of the situation, and no way to handle delayed rewards.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Up next
&lt;/h3&gt;

&lt;p&gt;So machines can now adapt reliably to noisy feedback. But what if the feedback comes &lt;em&gt;late&lt;/em&gt;, and what if the "learner" isn't a tidy algorithm at all, but a &lt;strong&gt;neuron&lt;/strong&gt;? In the 1970s, Harry Klopf proposed exactly that: neurons as tiny, pleasure-seeking units. Around the same time, Paul Werbos quietly described an idea that would later be famous as &lt;strong&gt;backpropagation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next: Blog 6 - The "Hedonistic" Revival: Klopf's Pleasure-Seeking Neurons and Werbos's Hidden Backpropagation (1972-1980).&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>RL 4: Early heuristics and the birth of Temporal Difference learning (1959–1968)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Fri, 25 Sep 2026 15:29:09 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-4-early-heuristics-and-the-birth-of-temporal-difference-learning-1959-1968-1hnb</link>
      <guid>https://dev.to/mitanshgor/rl-4-early-heuristics-and-the-birth-of-temporal-difference-learning-1959-1968-1hnb</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Bellman's math told you how to act perfectly — on paper. 1959 computers had neither the memory nor the map of reality to run it. So a few stubborn engineers cheated their way to something that actually worked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arthur Samuel (1959)&lt;/strong&gt; swapped an impossible checkers lookup table for a &lt;strong&gt;scoring function&lt;/strong&gt; — a formula with adjustable weights, trained by playing itself. His real breakthrough wasn't the 1962 headline win (which, spoiler, gets more impressive the more you learn how it actually went). It was an idea called &lt;strong&gt;Temporal Difference (TD) learning&lt;/strong&gt;: don't wait for the game to end — learn from the gap between what you predicted a moment ago and what you predict now. No rulebook required. That's &lt;strong&gt;model-free&lt;/strong&gt; learning, and it turns out to be the exact same rule psychologists later used to explain Pavlov's dogs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Donald Michie's MENACE (1961)&lt;/strong&gt; did something similar with 304 matchboxes and coloured beads — but learned a &lt;strong&gt;policy&lt;/strong&gt; ("what should I do?") instead of a &lt;strong&gt;value&lt;/strong&gt; ("how good is this?"). Value-learning and policy-learning are the two ancestors of basically every RL algorithm running today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Minsky (1961)&lt;/strong&gt; put a name on why any of this was hard in the first place: the &lt;strong&gt;credit-assignment problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Michie's BOXES (1968)&lt;/strong&gt; removed the last training wheel — a human teacher — and balanced a physical pole using nothing but "it fell over" as feedback.&lt;/p&gt;

&lt;p&gt;Every system in this post assumes the world is reliable. Blog 5 breaks that assumption.&lt;/p&gt;




&lt;h2&gt;
  
  
  The blueprint had a bill attached
&lt;/h2&gt;

&lt;p&gt;Bellman's equation is one of those rare results that's simultaneously beautiful and completely useless.&lt;/p&gt;

&lt;p&gt;Beautiful, because it tells you the &lt;em&gt;exact&lt;/em&gt; optimal move, always. Useless, because to run it you need two things handed to you first: every possible state of the world, written down, and the exact odds of moving between them, also written down.&lt;/p&gt;

&lt;p&gt;Neither exists. Computers in 1959 topped out around 32,768 words of memory — smaller than a single photo on your phone today. Checkers alone has roughly 500 billion possible positions. And the "odds of every outcome" problem is even worse than the memory one — more on that in a second.&lt;/p&gt;

&lt;p&gt;So the people actually trying to build this did what engineers always do when elegant theory meets a real budget: they cheated. One of the most important cheats in AI history started with a man, a room-sized vacuum-tube computer, and a game of checkers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3ewlex9fi8murgw8zlb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq3ewlex9fi8murgw8zlb.png" alt="Memory size-comparison graphic" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Three walls, one problem each
&lt;/h2&gt;

&lt;p&gt;Picture yourself in 1959, staring at Bellman's equation, actually trying to build the thing. You'd hit these three walls, in roughly this order, and none of them have an easy way around them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 1 — Memory.&lt;/strong&gt; Store every situation in a table and the table explodes. Tic-tac-toe: ~5,000 positions, fine. Checkers: ~500 billion. Chess: ~10⁴⁵. Bellman called this the &lt;strong&gt;curse of dimensionality&lt;/strong&gt; — add one variable, and your table doesn't grow, it detonates. Lesson: you can't memorise your way to intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 2 — No rulebook.&lt;/strong&gt; Bellman's math needs &lt;code&gt;P(s'|s,a)&lt;/code&gt; — the odds of every outcome, for every action, in advance. Nobody has that spreadsheet. A self-driving car has no table for "will this pedestrian step off the curb." Reality just doesn't ship with its own source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wall 3 — The score becomes the goal.&lt;/strong&gt; Turn "behave well" into a number, and machines will take that number &lt;em&gt;extremely&lt;/em&gt; literally. Reward a robot vacuum for movement, and it'll ram the same wall forever, racking up points and cleaning nothing — and from its own perspective, winning. Today we'd call this &lt;strong&gt;reward hacking&lt;/strong&gt;. In 1959 it didn't have a name yet, just a very confused engineer staring at the output.&lt;/p&gt;

&lt;p&gt;Samuel is about to dent Walls 1 and 2. Michie dents Wall 1 from a totally different angle. Wall 3 is still standing today — it's a large chunk of why "AI alignment" is now a job title.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwsv2zgjyie607ag8z1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwsv2zgjyie607ag8z1m.png" alt="one clean 3-icon graphic" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Arthur Samuel and the machine that learned checkers
&lt;/h2&gt;

&lt;p&gt;In the 1950s, the prevailing wisdom was blunt: computers execute, they don't learn. A program does exactly what it's told, forever, full stop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoi4m3bahw70ytzuvsym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoi4m3bahw70ytzuvsym.png" alt="Arthur Samuel" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ibm.com/history/early-games" rel="noopener noreferrer"&gt;Arthur Samuel, an IBM&lt;/a&gt; engineer, didn't buy it. He picked checkers — not chess — as his test case. Deep enough to need real strategy, small enough that a 1950s machine stood a chance. He started in 1952 on the IBM 701 and by 1959 had published work that put the phrase "machine learning" into circulation for the first time.&lt;/p&gt;

&lt;p&gt;His machine, the IBM 704, maxed out at 32,768 words of memory. Storing every checkers position wasn't "hard" — it was short by seven orders of magnitude. So instead of trying to be &lt;em&gt;comprehensive&lt;/em&gt;, Samuel made the machine &lt;em&gt;opinionated&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  A scoring function instead of a lookup table
&lt;/h3&gt;

&lt;p&gt;Throw away the table. Replace it with a formula that squeezes an entire board into one number: high = "good for me," low = "bad for me." The machine has no idea &lt;em&gt;why&lt;/em&gt; — it just needs a number it can push upward.&lt;/p&gt;

&lt;p&gt;If blog 3's &lt;code&gt;V(s)&lt;/code&gt; was an exact number, computed by sweeping every state until the answer converged — this is the same object, wearing a disguise. Samuel's scoring function &lt;em&gt;is&lt;/em&gt; &lt;code&gt;V(s)&lt;/code&gt;. The difference is that nobody can compute it exactly here, so the machine has to guess it, and improve its guess through play instead of through a formula that already has the whole map.&lt;/p&gt;

&lt;p&gt;That number was built from hand-picked &lt;strong&gt;features&lt;/strong&gt; — piece count, king count, board control, mobility — each with a &lt;strong&gt;weight&lt;/strong&gt; saying how much the machine currently trusts it. Score = features × weights, summed.&lt;/p&gt;

&lt;p&gt;Here's the part that still holds up today: the weights weren't fixed. A feature that kept predicting wins got trusted more. One that kept misleading the machine got trusted less, or dropped entirely and swapped for a new candidate. The machine wasn't just learning checkers — it was learning &lt;em&gt;what was worth paying attention to&lt;/em&gt;. That's the same basic instinct behind feature learning in neural networks, six decades early.&lt;/p&gt;

&lt;h3&gt;
  
  
  Self-play
&lt;/h3&gt;

&lt;p&gt;Samuel then had the program play itself. A "student" copy tries tweaked weights against a "teacher" copy running the current best settings. Student wins consistently → student becomes the new teacher → repeat.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujvxs9dmpdyswruhyapj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fujvxs9dmpdyswruhyapj.png" alt="Self-play" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This loop is, structurally, identical to what DeepMind ran in 2016 to build AlphaGo. The hardware went from vacuum tubes to TPU pods. The logic didn't change at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  The famous win (and the asterisk nobody mentions)
&lt;/h3&gt;

&lt;p&gt;In 1962, Samuel's program beat a checkers player named Robert Nealey, and IBM's press release turned it into the first-ever headline about a machine beating a human at a strategy game.&lt;/p&gt;

&lt;p&gt;What usually gets left out: Nealey wasn't state champion yet at the time (that came four years later), he beat the program in a rematch the following year, and by 1966 Samuel's program lost eight straight games to serious competition. None of that makes the work less real — it just moves the story from "magic trick" to "science": genuine learning, with a genuine, visible ceiling.&lt;/p&gt;

&lt;h3&gt;
  
  
  The ceiling Samuel could see from day one
&lt;/h3&gt;

&lt;p&gt;Every strategic idea the program ever had came from a feature Samuel typed in by hand. If he never thought to encode "board control matters," the machine could never discover it on its own. It could re-weight human knowledge with superhuman patience — but it couldn't generate knowledge that wasn't already sitting in the box.&lt;/p&gt;

&lt;p&gt;That single limitation defined the next thirty years of AI research, and it's exactly the problem deep learning was eventually built to solve: stop handing the machine features, let it find its own.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A name for the missing piece:&lt;/strong&gt; Marvin Minsky, in 1961, pointed at exactly this gap and called it the &lt;strong&gt;credit-assignment problem&lt;/strong&gt; — with only a final win or loss, which of a hundred earlier decisions actually deserves the credit? He specifically called out Samuel's scoring updates as the first real attempt at an answer: doling out partial credit one move at a time instead of waiting for the final verdict. That's the problem the rest of this post is trying to crack.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Memorise, or generalise?
&lt;/h2&gt;

&lt;p&gt;Samuel's scoring function created a fork in the road that reinforcement learning is still walking down today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5ir2p8l9qu2x9kiq6de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5ir2p8l9qu2x9kiq6de.png" alt="Memorise, or generalise" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;His first instinct was &lt;strong&gt;rote learning&lt;/strong&gt;: store exact positions and how they turned out, replay the good ones when they reappear. Works great for small games. But nudge a single piece and the "memory" is worthless — that exact position has never happened before, so there's nothing to look up. It's a lookup table wearing a trench coat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generalisation&lt;/strong&gt; was the fix: describe a board by its features instead of memorising the whole thing. Now a position the machine has never seen still gets a sensible score, because it's &lt;em&gt;described&lt;/em&gt;, not &lt;em&gt;recognised&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Table lookup asks "have I seen this exact thing?" Generalisation asks "what is this like?" Only the second question scales.&lt;/p&gt;

&lt;p&gt;Samuel's update rule for the weights:&lt;/p&gt;

&lt;p&gt;Δw_i = α · [V_actual − V_predicted] · f_i&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Δw_i — how much to nudge feature i's weight&lt;/li&gt;
&lt;li&gt;α — learning rate: how boldly to react to new evidence&lt;/li&gt;
&lt;li&gt;[V_actual − V_predicted] — the surprise&lt;/li&gt;
&lt;li&gt;f_i — how present that feature was in this position&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you remember one sentence from this whole post, make it this: &lt;strong&gt;learning is the size of your mistake, multiplied by how willing you are to change your mind.&lt;/strong&gt; Everything from here on is a variation on that one bracket.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thinking deeper on a slower machine: alpha-beta pruning
&lt;/h2&gt;

&lt;p&gt;One quick detour, and it earns its place here: self-play only works if you can play thousands of games against yourself, and thousands of games only fits into a reasonable afternoon if each individual game doesn't take forever to think through. That's the problem this section solves.&lt;/p&gt;

&lt;p&gt;The IBM 704 was unbelievably slow by today's standards — looking twenty moves ahead by brute force would've taken longer than the universe has existed. So Samuel needed to skip most of the game tree without missing anything that mattered.&lt;/p&gt;

&lt;p&gt;Credit where due: Samuel used &lt;strong&gt;alpha-beta pruning&lt;/strong&gt;, but didn't invent it. John McCarthy proposed it at the 1956 Dartmouth workshop; Hart and Edwards formalised it in 1961; Knuth and Moore gave it full analysis in 1975. Samuel had a working version quietly running in the background — he just thought the learning parts were the interesting bit. (He was right.)&lt;/p&gt;

&lt;p&gt;The idea: as the machine explores possible futures, it tracks the best result it can already guarantee (&lt;strong&gt;alpha&lt;/strong&gt;) and the worst its opponent can already force (&lt;strong&gt;beta&lt;/strong&gt;). The moment a branch is provably worse than something already locked in, the machine stops exploring it entirely — not "reads it faster," &lt;em&gt;stops&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Restaurant analogy: someone tells you "the other place has a two-hour wait." You don't need the menu or the parking situation. You're not going. Branch closed.&lt;/p&gt;

&lt;p&gt;Crucially, this is &lt;strong&gt;lossless&lt;/strong&gt; — it finds the exact same best move as checking everything, just without wasting time on futures that can't matter. It's also a technique with real staying power: it was the backbone of Deep Blue, the chess machine that beat world champion Garry Kasparov in 1997, decades after Samuel quietly used it for checkers.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://drive.google.com/file/d/1wk6siVlagwB9-13cf-0dbWVwrvXabgeV/view?usp=sharing" rel="noopener noreferrer" class="c-link"&gt;
            pruning comparision - Google Drive
          &lt;/a&gt;
        &lt;/h2&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fssl.gstatic.com%2Fdocs%2Fdoclist%2Fimages%2Fdrive_favicon_2026_32dp.png" width="32" height="32"&gt;
          drive.google.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;/h2&gt;

&lt;h2&gt;
  
  
  The idea that mattered most: learning from your own changing mind
&lt;/h2&gt;

&lt;p&gt;This is the part that echoes into every modern RL system, and it's easy to undersell because it sounds so small.&lt;/p&gt;

&lt;h3&gt;
  
  
  The old assumption
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4xnmc7j8ju2h73c65rm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4xnmc7j8ju2h73c65rm.png" alt="old assumption" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 1950s default: learning happens at the &lt;em&gt;end&lt;/em&gt;. Play the whole game, see who won, then work out what went wrong. This became known as &lt;strong&gt;Monte Carlo learning&lt;/strong&gt; — and it's brutally slow. You need a full game before learning anything, and if the game runs 100 moves, one noisy final signal has to somehow get distributed across all 100 decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Samuel's question: why wait?
&lt;/h3&gt;

&lt;p&gt;The machine already had a second opinion available, one move later, for free. If a position looked 70% winning after move 10, and only 50% winning after move 11 — something was already learned, right there, with no need to finish the game. Your own estimate moved, and estimates don't move for no reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkl8ofqe1zuuxx7i43yj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkl8ofqe1zuuxx7i43yj9.png" alt="TD improments" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Real-life version: you leave home expecting a 20-minute drive. Ten minutes in, you hit an empty motorway and revise to "7 more minutes." You haven't arrived yet, you don't know the true total — and you've unmistakably learned something the moment your prediction jumped.&lt;/p&gt;

&lt;p&gt;That's the whole trick: learn from the &lt;em&gt;gap between consecutive predictions&lt;/em&gt;, not from the final answer. It sidesteps Minsky's credit-assignment problem rather than solving it head-on — each move only ever has to explain the &lt;em&gt;next&lt;/em&gt; move, not the whole game.&lt;/p&gt;

&lt;h3&gt;
  
  
  The formula
&lt;/h3&gt;

&lt;p&gt;For a game like checkers, where nothing scores until someone wins:&lt;/p&gt;

&lt;p&gt;V(S_t) ← V(S_t) + α [ V(S_t+1) − V(S_t) ]&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V(S_t) — current guess about this position&lt;/li&gt;
&lt;li&gt;V(S_t+1) — the guess one move later&lt;/li&gt;
&lt;li&gt;[V(S_t+1) − V(S_t)] — the &lt;strong&gt;TD error&lt;/strong&gt;: how wrong I just turned out to be&lt;/li&gt;
&lt;li&gt;α — learning rate: too high and it's jittery, too low and it barely moves&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In plain English: nudge what you believed toward what you now believe, in proportion to how surprised you are.&lt;/p&gt;

&lt;p&gt;The general version below isn't a new idea — it's the exact same bracket with two extra pieces bolted on, so you can see them coming rather than guessing where they came from. It adds in any reward collected along the way, plus a discount for how much future value matters:&lt;/p&gt;

&lt;p&gt;V(S_t) ← V(S_t) + α [ r_t+1 + γ V(S_t+1) − V(S_t) ]&lt;/p&gt;

&lt;p&gt;Checkers collapses back to the simple version because nothing is scored mid-game (r = 0) and a win in 10 moves is worth exactly as much as a win now (γ = 1).&lt;/p&gt;

&lt;h3&gt;
  
  
  The déjà vu moment
&lt;/h3&gt;

&lt;p&gt;That bracket should look familiar if animal learning is on your radar at all — and if you've been following this series, it should ring a very specific bell. This is the &lt;strong&gt;prediction error&lt;/strong&gt; term flagged back in Blog 3, finally getting the job it was promised. Same idea, same shape, just a new name and a new job description: back then it fired once per trial, at the end. Here, it fires on every single move.&lt;/p&gt;

&lt;p&gt;Pavlov's dogs weren't learning from bells — they were learning from &lt;em&gt;being wrong about bells&lt;/em&gt;. A decade after Samuel, psychologists Rescorla and Wagner wrote down almost the identical rule to explain it: change your belief in proportion to your error. Different letters, same bracket — reality minus expectation, scaled by how much you're willing to update.&lt;/p&gt;

&lt;p&gt;An IBM engineer trying to save vacuum-tube cycles, and two psychologists trying to explain salivating dogs, landed on the same equation from completely opposite ends of science, with zero contact between them. That's not a coincidence — it's a strong hint that prediction error is something close to fundamental about what learning actually &lt;em&gt;is&lt;/em&gt;. (It gets better: in the 1990s, Wolfram Schultz found dopamine neurons firing in a pattern that looks almost exactly like a TD error signal. More on that in a later post.)&lt;/p&gt;

&lt;p&gt;And notice what TD learning never needed: the rulebook Wall 2 said was impossible to get. Just the current state, the next state, and two estimates. That's &lt;strong&gt;model-free&lt;/strong&gt; reinforcement learning — arguably the single most important idea in this post — quietly running on a vacuum-tube computer in 1959, almost thirty years before Richard Sutton formalised it as TD(λ) in 1988.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F96twyh8rv4xoua2ntler.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F96twyh8rv4xoua2ntler.png" alt="Monte Carlo VS TD" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  MENACE: reinforcement learning built out of matchboxes
&lt;/h2&gt;

&lt;p&gt;Samuel had IBM's hardware. British researcher Donald Michie had a rather different constraint: no computer access at all. So in 1961, he built one out of matchboxes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MENACE&lt;/strong&gt; — the Matchbox Educable Noughts And Crosses Engine — used 304 matchboxes, each labelled with a tic-tac-toe position MENACE might face, and filled with coloured beads. Each colour maps to one legal move.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To move:&lt;/strong&gt; find the matching box, shake it, pull a bead blind. Its colour is the move. Leave the box open — you'll need the trail later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To learn:&lt;/strong&gt; after the game, walk back along the trail of open boxes. Win → return the bead played, plus three more of the same colour. Draw → add just one. Loss → the bead simply isn't returned; it's gone. More beads of a colour means a better chance of drawing it next time.&lt;/p&gt;

&lt;p&gt;Michie played roughly 220 games against it over a weekend. It went from flailing randomly to essentially unbeatable.&lt;/p&gt;

&lt;h3&gt;
  
  
  The detail worth noticing
&lt;/h3&gt;

&lt;p&gt;Michie didn't load every box with the same number of beads. Early-game boxes started with about four beads per move; late-game boxes tapered down toward one. That's a deliberately engineered &lt;strong&gt;exploration schedule&lt;/strong&gt;. Early moves are far from the outcome, so any one game barely tells you if they were good — you want MENACE to keep trying alternatives. Late moves sit right next to the result, so their feedback is trustworthy and can be locked in fast. That's the &lt;strong&gt;explore vs. exploit&lt;/strong&gt; trade-off, solved in 1961 with nothing but bead-counting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this is a plot point, not a party trick
&lt;/h3&gt;

&lt;p&gt;Samuel's program learned to answer "how good is this position?" MENACE never asked that question — it has no concept of a position being worth 0.7. It only tracks "which move should I make more often from here?"&lt;/p&gt;

&lt;p&gt;In blog 3's terms: MENACE is growing a &lt;strong&gt;policy&lt;/strong&gt; — &lt;code&gt;π&lt;/code&gt;, a state-to-action lookup — directly. It never computes a value for anything along the way. That's the split worth holding onto:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Samuel&lt;/th&gt;
&lt;th&gt;Michie&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Learns&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Values&lt;/strong&gt; — how good is this state?&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;A policy&lt;/strong&gt; — what should I do here?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stores&lt;/td&gt;
&lt;td&gt;Feature weights&lt;/td&gt;
&lt;td&gt;Action probabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern descendant&lt;/td&gt;
&lt;td&gt;Value-based methods — learn a score for each move, then just pick the best one (Q-learning, and its neural-network upgrade DQN)&lt;/td&gt;
&lt;td&gt;Policy-gradient methods — skip the scoring step, learn the action probabilities directly (REINFORCE, and its more stable modern version PPO)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two men, two continents, same decade — and they'd independently split reinforcement learning into the two halves it still has today. Modern RL doesn't pick a winner; it runs both at once. &lt;strong&gt;Actor-Critic&lt;/strong&gt; methods (more on these in a later post) are literally a Critic estimating values (Samuel's job) paired with an Actor adjusting action probabilities (Michie's job), each sharpening the other.&lt;/p&gt;

&lt;p&gt;MENACE also proves something worth sitting with: reinforcement learning isn't a property of silicon. It's a mathematical principle. Run it on vacuum tubes, neurons, or 304 matchboxes on a Sunday afternoon — what matters is the loop: act, observe the consequence, adjust, repeat.&lt;/p&gt;

&lt;p&gt;It also hit the exact same wall Samuel did: every position needs its own box, and one extra square collapses the shelf. Same curse, cardboard edition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Michie didn't stop there.&lt;/strong&gt; In 1968, with R. A. Chambers, he took the matchbox idea into physics: &lt;strong&gt;BOXES&lt;/strong&gt;, balancing a pole on a moving cart using nothing but a bang when it fell over. Widrow and Smith had balanced the same pole in 1964 — but with a human demonstrating the right move at each step. BOXES threw the teacher out entirely: no demonstration, just eventual failure walked backward through whichever boxes were open. The one new trick it needed was &lt;strong&gt;state aggregation&lt;/strong&gt; — chopping a continuous space (pole angle, cart speed) into discrete chunks, since you can't label a matchbox for infinitely many positions. That's the field's first honest step toward &lt;strong&gt;function approximation&lt;/strong&gt; — a plain-English way of saying "estimate the value instead of memorising it," the same escape hatch this whole post keeps circling back to. Cart-pole balancing went on to become RL's most reused benchmark ever since.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxgx4blsdq6yrfszi4xw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxgx4blsdq6yrfszi4xw8.png" alt="MENACE matchbox setup" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Two roads, one open question
&lt;/h2&gt;

&lt;p&gt;By the late 1960s, two things were true at once. Samuel and Michie both had systems that genuinely learned from experience — no rulebook, no complete map of the world, and they visibly got better over time. But nobody could prove any of it. No convergence guarantee, no theorem saying "this reaches the optimal policy" — just clever hacks that happened to hold up on small problems.&lt;/p&gt;

&lt;p&gt;Bellman's framework had the opposite problem: flawless proofs, unusable in practice.&lt;/p&gt;

&lt;p&gt;Which set up the question the field spent the next twenty years chasing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Can you keep Bellman's guarantees without needing Bellman's rulebook?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyywrw5nv22v0bsxd3cbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyywrw5nv22v0bsxd3cbp.png" alt="modelfree vs modelbased" width="440" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That question is the birth of model-free reinforcement learning — and chasing it eventually pushes the field toward systems that learn their own features instead of borrowing a human's. Which is to say: toward neural networks.&lt;/p&gt;

&lt;p&gt;Worth sitting with for a second before we move on: the technique that trains most modern chatbots to be helpful — RLHF, reinforcement learning from human feedback — is a direct descendant of exactly this idea. No rulebook for "what makes a good response," just a reward signal and a model updating itself against its own predictions. The line from a matchbox in 1961 to a language model in 2026 runs straight through this post.&lt;/p&gt;

&lt;p&gt;But not yet. First, someone has to ask a harder version of the question.&lt;/p&gt;




&lt;h2&gt;
  
  
  Coming up next
&lt;/h2&gt;

&lt;p&gt;Samuel and Michie both had one thing quietly working in their favour: their worlds behaved. Move a checker, it stays moved. Draw a bead, that's the move you play. The environment was unknown, but at least it was &lt;em&gt;reliable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now break that assumption. What if pressing the same button in the same situation works 70% of the time and fails the other 30%, for no reason you can see? A single result stops meaning anything — it might just be noise. You need to learn from distributions, not events, while still acting sensibly under real uncertainty.&lt;/p&gt;

&lt;p&gt;That discipline was being built in parallel, largely by control theorists who weren't talking to the game-playing crowd at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next up — RL 5: Learning Automata and Stochastic Environments (1961–1974).&lt;/strong&gt; How do you make good decisions when the world itself won't give you a straight answer?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Series index:&lt;br&gt;
Blog 1 — Biological foundations and the Law of Effect&lt;br&gt;
Blog 2 — Classical conditioning and prediction&lt;br&gt;
Blog 3 — Bellman, MDPs and Dynamic Programming&lt;br&gt;
Blog 4 — Early heuristics and the birth of TD learning (this post)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>RL 3: Bellman Equations and Markov Decision Processes (1950s–1960s)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Fri, 18 Sep 2026 20:47:23 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-3-bellman-equations-and-markov-decision-processes-1950s-1960s-2pp0</link>
      <guid>https://dev.to/mitanshgor/rl-3-bellman-equations-and-markov-decision-processes-1950s-1960s-2pp0</guid>
      <description>&lt;h2&gt;
  
  
  Where we left off
&lt;/h2&gt;

&lt;p&gt;Two quick reminders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thorndike (1898)&lt;/strong&gt; watched cats escape a puzzle box and gave us the &lt;strong&gt;Law of Effect&lt;/strong&gt;: do something, get a good result, do it again. Get a bad result, stop. Learning is bookkeeping over consequences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 2&lt;/strong&gt; turned that idea into hardware. Shannon's mouse ran a maze and remembered the route. Minsky's SNARC strengthened the wires that led to good outcomes.&lt;/p&gt;

&lt;p&gt;Both worked. Both were missing the same thing.&lt;/p&gt;

&lt;p&gt;Thorndike's cat knew &lt;em&gt;"pulling that loop felt good."&lt;/em&gt; It did &lt;strong&gt;not&lt;/strong&gt; know it was three moves from freedom. Shannon's mouse could replay a path, but it couldn't tell you why one path was better than another.&lt;/p&gt;

&lt;p&gt;Nobody had a word for this yet:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt; — a number attached to a situation that says &lt;em&gt;how good does the future look from right here?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one missing number is what this whole post is about.&lt;/p&gt;




&lt;h3&gt;
  
  
  Side note: the biologists were chasing the same number
&lt;/h3&gt;

&lt;p&gt;Worth thirty seconds, because it makes the maths feel less alien.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rescorla and Wagner (1972)&lt;/strong&gt; showed that animals don't learn from repetition. They learn from &lt;strong&gt;surprise&lt;/strong&gt;. If a bell already predicts food perfectly, adding a light next to the bell teaches the animal almost nothing about the light. There's no surprise left to learn from.&lt;/p&gt;

&lt;p&gt;Their rule, in plain English:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;new belief = old belief + (small step) × (what actually happened − what I expected)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That last bracket — reality minus expectation — is called &lt;strong&gt;prediction error&lt;/strong&gt;. Hold onto it. It comes back in Blog 4 with a much bigger job.&lt;/p&gt;

&lt;p&gt;(Yes, 1972 is out of order here. I'm putting it early because it explains "value" better than a grid does.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98aodvd1bi2qni84k7q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98aodvd1bi2qni84k7q9.png" alt="Prediction error diagram" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter Richard Bellman
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28nj9nvict7epd44gyk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28nj9nvict7epd44gyk0.png" alt="Richard Bellman" width="146" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1949, a mathematician named &lt;strong&gt;Richard Bellman&lt;/strong&gt; started working at &lt;strong&gt;RAND&lt;/strong&gt;, a US think tank. His job was a specific shape of problem: you make a choice, the world changes, then you have to choose again. Missile guidance. Supply planning. Anything where today's decision quietly reshapes tomorrow's options.&lt;/p&gt;

&lt;p&gt;He cracked it. Then he needed a name for it, So he picked two words that sounded harmless and industrial: &lt;strong&gt;Dynamic Programming&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;(The story has probably been tidied up over the years — the dates don't quite line up — but the name stuck, and it's now one of the most important terms in computer science.)&lt;/p&gt;

&lt;p&gt;Here's the problem he was actually solving.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem, in the form we'll use all post
&lt;/h2&gt;

&lt;p&gt;Forget missiles. Here's the setup we'll use for everything that follows.&lt;/p&gt;

&lt;p&gt;You're on a grid. You start in one corner. The goal is somewhere else. Every step costs you a little energy. Some cells are bad news. You want to reach the goal having collected as much reward as possible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cx1d3ep6pxzlra06vvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cx1d3ep6pxzlra06vvm.png" alt="grid" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Easy to describe. Genuinely nasty to solve &lt;em&gt;systematically&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The obvious approach is to list every possible path and pick the best. That works right up until it catastrophically doesn't. Paths multiply exponentially with grid size. 10×10 is already unpleasant. 100×100 is hopeless. Bellman later gave this failure mode a name — &lt;strong&gt;the curse of dimensionality&lt;/strong&gt; — and we'll come back to it at the end, because it's the villain of the whole post.&lt;/p&gt;

&lt;p&gt;So he needed a fundamentally different kind of reasoning.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dynamic Programming: solve it backward, and only solve it once
&lt;/h2&gt;

&lt;p&gt;Bellman's core insight is called the &lt;strong&gt;Principle of Optimality&lt;/strong&gt;. Here it is in his words:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a mouthful. In human:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If the best route from A to C goes through B, then the B-to-C part of it must itself be the best route from B to C.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because if it weren't — if there were a better way from B to C — you'd just swap it in and get a better A-to-C route. Contradiction. Done.&lt;/p&gt;

&lt;p&gt;Sounds trivial. It isn't, because of what it licenses you to do:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You only ever have to solve each sub-problem once.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you know the best way from B onward, &lt;em&gt;every&lt;/em&gt; route that passes through B can reuse that answer for free. No recomputation. That's Dynamic Programming: chop a giant sequential problem into overlapping sub-problems, solve them from the end backward, and cache the answers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f9yzz0hsk9op7rj7817.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f9yzz0hsk9op7rj7817.png" alt="stare-reardloop" width="799" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;backward&lt;/strong&gt; part is the counterintuitive bit and it's worth sitting with. Bellman didn't ask "what's my best first move?" He asked &lt;strong&gt;"what's my best &lt;em&gt;last&lt;/em&gt; move?"&lt;/strong&gt; Then second-to-last. Then third-to-last, propagating backward until every square on the board has an answer.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;backward induction&lt;/strong&gt;, and it's not a historical curiosity — it is still, structurally, how modern RL agents plan.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoj8dzboblvy02ckek0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoj8dzboblvy02ckek0h.png" alt="backward induction" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hold onto this:&lt;/strong&gt; the future is easier to reason about than the past, because the future has an ending you can anchor to.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Five nouns you need before the equation shows up
&lt;/h2&gt;

&lt;p&gt;So: five nouns first. Equation after. All five together are called a &lt;strong&gt;Markov Decision Process (MDP)&lt;/strong&gt; — the formal container the maths lives in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F460d9r80ynde2ixbgf04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F460d9r80ynde2ixbgf04.png" alt="MDP diagram" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. State — &lt;code&gt;s&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Where you are. On the grid, "row 3, column 4." In chess, the board position. In a delivery robot, position &lt;em&gt;plus&lt;/em&gt; battery &lt;em&gt;plus&lt;/em&gt; whether it's holding a package. The full set of states is written &lt;code&gt;S&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Action — &lt;code&gt;a&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
What you can do from here. On the grid: up, down, left, right. The full set is &lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Transition — &lt;code&gt;P(s' | s, a)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Read it as: &lt;em&gt;"the probability of landing in state &lt;code&gt;s'&lt;/code&gt;, given that I was in &lt;code&gt;s&lt;/code&gt; and did &lt;code&gt;a&lt;/code&gt;."&lt;/em&gt; The apostrophe just means "next."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Reward — &lt;code&gt;R(s, a)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
A number the environment hands you for doing &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;s&lt;/code&gt;. This is where you, the designer, encode what "good" means. Reach the goal: +10. Take a step: −1. Fall in the pit: −100.&lt;/p&gt;

&lt;p&gt;Get this wrong and your agent will cheerfully optimise the wrong thing. Reward design is 90% of applied RL pain, and I'm not going to pretend otherwise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Policy — &lt;code&gt;π&lt;/code&gt; (pi)&lt;/strong&gt;&lt;br&gt;
Your strategy. A rule that maps &lt;em&gt;state → action&lt;/em&gt;. "When in this square, go right." That's it. A policy isn't a plan or a path — it's a lookup table of what to do &lt;em&gt;anywhere&lt;/em&gt; you might find yourself.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The whole field, in one sentence:&lt;/strong&gt; an MDP describes the world; a policy describes your behaviour in it; and the rest of RL is the search for the best policy.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9309bj0gu2w598yq1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz9309bj0gu2w598yq1s.png" alt="Reinforcement Learning loop" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  The one assumption holding all of this up
&lt;/h2&gt;

&lt;p&gt;There's a condition the whole framework quietly depends on, and it's called the &lt;strong&gt;Markov Property&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The future depends only on the present state — not on the history of how you got there.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3w2pfw16tjoscydeb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3w2pfw16tjoscydeb1.png" alt="stateIsEnough" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First reaction to this is usually: &lt;em&gt;that's obviously false, history matters all the time.&lt;/em&gt; Fair. But that's not quite what it says.&lt;/p&gt;

&lt;p&gt;It says &lt;strong&gt;history must already be baked into the state.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your robot's battery level affects the next decision, then battery level belongs &lt;em&gt;in the state definition&lt;/em&gt;. Once it's in there, you don't need to replay the last 50 timesteps — you just look at where you are now.&lt;/p&gt;

&lt;p&gt;Two quick examples to make it concrete:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chess is Markov.&lt;/strong&gt; The board position tells you everything. It doesn't matter whether you reached it through a brilliant sacrifice or a series of blunders — the position is the position.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poker is not Markov if your state is just "my cards."&lt;/strong&gt; Whether your opponent has been bluffing all night genuinely changes what you should do. Fix it by expanding the state to include betting history. Now it's Markov again — and much bigger. (Notice the trade you just made. That's foreshadowing.)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The neat way to say it:&lt;/strong&gt; the &lt;em&gt;state&lt;/em&gt; is allowed to have memory. The &lt;em&gt;policy&lt;/em&gt; isn't.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This assumption is exactly what makes RL computable. Without it, an agent would have to carry and process its entire past at every step. With it, a policy is just a lookup: current state in, action out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One more assumption, and it's a big one.&lt;/strong&gt; For this entire post, the agent is assumed to already &lt;strong&gt;know&lt;/strong&gt; &lt;code&gt;P&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt;. It knows the physics of the world and the reward structure before it takes a single step. That's called &lt;strong&gt;model-based&lt;/strong&gt; RL, and it's what makes the maths clean here.&lt;/p&gt;

&lt;p&gt;It is also completely unrealistic, and Blog 4 takes a sledgehammer to it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Return and γ: why "how good" needs a definition
&lt;/h2&gt;

&lt;p&gt;One more thing before the equation. If value means "how promising is the future from here," we need to say what &lt;em&gt;the future&lt;/em&gt; means numerically.&lt;/p&gt;

&lt;p&gt;Add up all the reward you'll collect from now until the end. That total is called the &lt;strong&gt;return&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Except there's a problem: if the task never ends, that sum runs to infinity, and "infinity" is a terrible thing to compare against another infinity. So Bellman introduced a &lt;strong&gt;discount factor, &lt;code&gt;γ&lt;/code&gt; (gamma)&lt;/strong&gt;, a number between 0 and 1. Reward one step away is multiplied by γ. Two steps away, γ². Three steps, γ³. And so on.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;G&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;span class="mbin mtight"&gt;+&lt;/span&gt;&lt;span class="mord mtight"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Two things fall out of this, and both matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mathematically:&lt;/strong&gt; the sum now converges. It's a geometric series. No infinities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Behaviourally:&lt;/strong&gt; γ is a &lt;strong&gt;personality dial.&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;γ near &lt;strong&gt;0&lt;/strong&gt; — a myopic agent. Only right now exists. It will grab the nearest +1 and ignore a +100 two steps away.&lt;/li&gt;
&lt;li&gt;γ near &lt;strong&gt;1&lt;/strong&gt; — a patient agent. Happy to eat a −1 today for a +100 later.&lt;/li&gt;
&lt;li&gt;γ = 0.9 — a reasonable default that says "about ten steps of foresight."&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's compound interest, run backward. A reward ten steps away at γ = 0.9 is worth about 35% of its face value today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fivqu2yfy9rbo9lxbnlf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fivqu2yfy9rbo9lxbnlf8.png" alt="Same grid solved three times" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Value: the number Thorndike's cat never had
&lt;/h2&gt;

&lt;p&gt;Now we can define the thing this whole post is chasing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;V(s)&lt;/code&gt; — the value of state &lt;code&gt;s&lt;/code&gt; — is the expected return you'll collect if you start in &lt;code&gt;s&lt;/code&gt; and behave well from there on.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the number the cat didn't have. The cat knew &lt;em&gt;"this felt good."&lt;/em&gt; A value function knows &lt;em&gt;"this square is worth 7.1, that one's worth 5.4, so go left."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And that's the whole trick: &lt;strong&gt;once every square has a number, choosing an action stops being a search problem and becomes a comparison.&lt;/strong&gt; Look at the neighbouring numbers. Walk toward the big one. Done.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bellman Equation
&lt;/h2&gt;

&lt;p&gt;In his 1957 book &lt;em&gt;Dynamic Programming&lt;/em&gt;, Bellman wrote down the recursion that ties all of this together:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The value of where you are = the best immediate reward you can grab + the discounted value of wherever you end up next.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every symbol is one of the five nouns you already know:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Reading&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;V(s)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how good it is to be here&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max_a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;you, choosing.&lt;/strong&gt; Try every action, keep the best&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;R(s, a)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;what you get right now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;γ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how much you care about later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;∑ P(s':s,a) · V(s')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the world, responding.Average over every place you might land, weighted by likelihood&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things I want to flag, because they're where people quietly lose the thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First: &lt;code&gt;max&lt;/code&gt; and &lt;code&gt;∑&lt;/code&gt; are doing opposite jobs.&lt;/strong&gt; The &lt;code&gt;max&lt;/code&gt; is the agent &lt;em&gt;choosing&lt;/em&gt;. The &lt;code&gt;∑&lt;/code&gt; is the world &lt;em&gt;rolling dice&lt;/em&gt;. You control your action. You do not control the outcome. If the transitions were deterministic, that &lt;code&gt;∑&lt;/code&gt; would collapse to a single term and disappear — it only exists because the world is uncertain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second: &lt;code&gt;V(s)&lt;/code&gt; appears on both sides.&lt;/strong&gt; That's not sloppy notation, it's the entire idea. The equation is &lt;strong&gt;self-referential&lt;/strong&gt; — the value of a state is defined in terms of the values of &lt;em&gt;other&lt;/em&gt; states.&lt;/p&gt;

&lt;p&gt;Which raises the obvious question: if V is defined in terms of V, how do you ever compute it?&lt;/p&gt;

&lt;p&gt;You guess, then you improve. Start with V = 0 everywhere (a wrong but harmless guess), apply the equation, get better numbers, apply again. The values stop changing when they're all consistent with each other. Mathematicians call that a &lt;strong&gt;fixed point&lt;/strong&gt; — the place where applying the rule doesn't change anything anymore.&lt;/p&gt;

&lt;p&gt;That "keeps changing until it doesn't" process is the entire computational game. And it's easier to believe once you've watched it happen, so let's watch it happen.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's actually put numbers on the board
&lt;/h2&gt;

&lt;p&gt;Here's the smallest example that shows the real behaviour. A corridor, four squares, then the goal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ S1 ][ S2 ][ S3 ][ S4 ][ GOAL ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actions: move left or move right. Deterministic — no ice.&lt;/li&gt;
&lt;li&gt;Every move costs &lt;strong&gt;−1&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Stepping into GOAL pays &lt;strong&gt;+10&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;γ = &lt;strong&gt;0.9&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;GOAL is terminal, so &lt;code&gt;V(GOAL) = 0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Work backward, exactly as Bellman said to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;S4&lt;/strong&gt; is one step from GOAL: &lt;code&gt;V(S4) = −1 + 10 + 0.9 × 0 =&lt;/code&gt; &lt;strong&gt;9.00&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S3&lt;/strong&gt; is one step from S4: &lt;code&gt;V(S3) = −1 + 0.9 × 9.00 =&lt;/code&gt; &lt;strong&gt;7.10&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S2:&lt;/strong&gt; &lt;code&gt;V(S2) = −1 + 0.9 × 7.10 =&lt;/code&gt; &lt;strong&gt;5.39&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;S1:&lt;/strong&gt; &lt;code&gt;V(S1) = −1 + 0.9 × 5.39 =&lt;/code&gt; &lt;strong&gt;3.85&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 3.85 ][ 5.39 ][ 7.10 ][ 9.00 ][ GOAL ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Look at what happened. &lt;strong&gt;The goal's reward leaked backward through the corridor and left a slope behind it.&lt;/strong&gt; The agent doesn't need a map, a plan, or a search. It just walks uphill. The value function turned a planning problem into a gradient you can follow like a scent trail.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://drive.google.com/file/d/1zEZ-xmnFXWbNvPaQeYPOpUamLs6qBp62/view?usp=sharing" rel="noopener noreferrer" class="c-link"&gt;
            Animated_heatmap_of_the_x_gr.mp4 - Google Drive
          &lt;/a&gt;
        &lt;/h2&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fssl.gstatic.com%2Fdocs%2Fdoclist%2Fimages%2Fdrive_favicon_2026_32dp.png" width="32" height="32"&gt;
          drive.google.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;h3&gt;
  
  
  Now watch it converge from nothing
&lt;/h3&gt;

&lt;p&gt;That was the answer. Here's the &lt;em&gt;process&lt;/em&gt; — starting from V = 0 everywhere and sweeping the equation across all four states repeatedly:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sweep&lt;/th&gt;
&lt;th&gt;V(S1)&lt;/th&gt;
&lt;th&gt;V(S2)&lt;/th&gt;
&lt;th&gt;V(S3)&lt;/th&gt;
&lt;th&gt;V(S4)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;td&gt;0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;−1.00&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9.00&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;−1.90&lt;/td&gt;
&lt;td&gt;−1.90&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7.10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;−2.71&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.39&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;3.85&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.39&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;3.85&lt;/td&gt;
&lt;td&gt;5.39&lt;/td&gt;
&lt;td&gt;7.10&lt;/td&gt;
&lt;td&gt;9.00&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things worth noticing here, and honestly this table is the most important object in the post:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Information travels exactly one square per sweep.&lt;/strong&gt; Sweep 1, only S4 knows the goal exists. Sweep 2, S3 finds out. It's a wavefront moving backward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The early numbers are hilariously wrong.&lt;/strong&gt; At sweep 3, S1 thinks it's worth −2.71 — it can only see step costs and no payoff yet. It's a pessimist with incomplete information. It gets over it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You don't need a stopping rule, you need a stopping &lt;em&gt;condition&lt;/em&gt;.&lt;/strong&gt; When a full sweep changes nothing, you're done. That's the fixed point, made of actual numbers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8grw8sbri68uc9p8788.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8grw8sbri68uc9p8788.png" alt="bar chart per sweep" width="671" height="926"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Howard's Policy Iteration: from knowing values to having a strategy
&lt;/h2&gt;

&lt;p&gt;Bellman gave us the value of every square. But there's a subtly separate question: how do you systematically build the &lt;strong&gt;strategy&lt;/strong&gt; — the policy — that goes with it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ronald Howard&lt;/strong&gt;, in his 1960 monograph &lt;em&gt;Dynamic Programming and Markov Processes&lt;/em&gt;, noticed the problem is circular:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To compute &lt;code&gt;V(s)&lt;/code&gt;, you need to know which policy &lt;code&gt;π&lt;/code&gt; the agent is following.&lt;/li&gt;
&lt;li&gt;To find the best &lt;code&gt;π&lt;/code&gt;, you need to know &lt;code&gt;V(s)&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Classic chicken and egg. Howard's answer: &lt;strong&gt;stop trying to do both at once. Alternate.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" alt="PE vs PI" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 — Policy Evaluation: "how good is my current strategy?"
&lt;/h3&gt;

&lt;p&gt;Freeze the policy. Don't try to improve it. Just ask: &lt;em&gt;if I followed this exact strategy forever, what would each state be worth?&lt;/em&gt;&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;))&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;))&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Notice the &lt;code&gt;max&lt;/code&gt; is gone.&lt;/strong&gt; There's no choosing here. &lt;code&gt;π(s)&lt;/code&gt; tells you what to do; you're just measuring the consequences. This isn't optimisation, it's &lt;em&gt;scorekeeping&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 2 — Policy Improvement: "could I do better?"
&lt;/h3&gt;

&lt;p&gt;Now take those scores and ask, at every state: &lt;em&gt;given what I now know things are worth, is there an action better than the one my policy currently prescribes?&lt;/em&gt; If yes, switch to it.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;π&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;ar&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;π&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;arg max&lt;/code&gt; vs &lt;code&gt;max&lt;/code&gt;, since this trips everyone up:&lt;/strong&gt; &lt;code&gt;max&lt;/code&gt; returns &lt;em&gt;the best value&lt;/em&gt;. &lt;code&gt;arg max&lt;/code&gt; returns &lt;em&gt;the action that achieved it&lt;/em&gt;. Evaluation wants the number; improvement wants the move.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  And repeat
&lt;/h3&gt;

&lt;p&gt;Evaluate. Improve. Evaluate. Improve. Stop when an improvement step changes nothing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0vlv9oo30xbnr0swsa5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0vlv9oo30xbnr0swsa5.png" alt="Policy Eval and Improvement" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Howard proved two things about this loop that are genuinely reassuring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The greedy step never makes the policy worse.&lt;/strong&gt; Every improvement is an improvement or a tie. It can't wander off toward a worse policy — the local, greedy move is globally safe here. (That's a strong guarantee, and one that quietly evaporates once we start using neural networks in later posts.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On a finite MDP, it terminates in a finite number of iterations.&lt;/strong&gt; There are only finitely many policies, you never repeat one, so you must stop. Usually in a handful of rounds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0n70gh4uwe9sqkz4sog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0n70gh4uwe9sqkz4sog.png" alt="Eval Improv General idea" width="799" height="695"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And here's the part that should give you a small jolt:&lt;/strong&gt; that two-role split — one part measuring, one part deciding — is the direct ancestor of the &lt;strong&gt;Actor–Critic&lt;/strong&gt; architectures we'll get to in Blog 7. The Critic does Policy Evaluation. The Actor does Policy Improvement.&lt;/p&gt;

&lt;p&gt;That structure wasn't invented for deep learning. It was sitting in a 1960 operations research monograph the whole time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1sj0dabx5pxpe0c7fu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1sj0dabx5pxpe0c7fu0.png" alt="actor-critic" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Value Iteration: the impatient version
&lt;/h2&gt;

&lt;p&gt;Policy Iteration is a bit fussy. It insists on &lt;em&gt;fully&lt;/em&gt; evaluating a policy — running evaluation to convergence — before it'll consider improving anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Value Iteration&lt;/strong&gt; says: why wait? Fold the improvement directly into the update.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;←&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop"&gt;max&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size4"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mop op-limits"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size3 size1 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="mop op-symbol large-op"&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;a&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;s&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size4"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The &lt;code&gt;max&lt;/code&gt; is back, and it's inside the loop.&lt;/strong&gt; Every single update implicitly re-decides the best action. No separate improvement phase exists.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkisnepo5w1ik802tpuqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkisnepo5w1ik802tpuqo.png" alt="Value iteration code loop" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Value Iteration never stores a policy at all. It just hammers on the value function until it settles, and &lt;em&gt;then&lt;/em&gt; you read the policy off: stand in each state, look at the neighbours, take the action pointing at the biggest number.&lt;/p&gt;

&lt;p&gt;(That sweep table you looked at earlier? That was Value Iteration. You've already seen it run.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol3kxq76qxut4anbugrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fol3kxq76qxut4anbugrn.png" alt="Value iteration diagram" width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Policy Iteration vs Value Iteration, side by side
&lt;/h2&gt;

&lt;p&gt;Same equation, same destination, different temperament.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Policy Iteration is the coach who watches the entire game.&lt;/strong&gt; Films it. Writes a 40-page report. Rewrites the playbook from scratch before the next match. Few iterations, each one expensive and each one a big leap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Value Iteration is the coach who stops play after every snap.&lt;/strong&gt; &lt;em&gt;"Stop — standing three feet left would've been worth two more points."&lt;/em&gt; Cheap per update, but it needs a lot of them. Constantly nudging everyone's understanding of the field.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Policy Iteration&lt;/th&gt;
&lt;th&gt;Value Iteration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Explicit policy?&lt;/td&gt;
&lt;td&gt;Yes, maintained separately&lt;/td&gt;
&lt;td&gt;No, implicit in the values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;max&lt;/code&gt; in the update?&lt;/td&gt;
&lt;td&gt;Only in the improvement step&lt;/td&gt;
&lt;td&gt;Every update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost per iteration&lt;/td&gt;
&lt;td&gt;High (full evaluation)&lt;/td&gt;
&lt;td&gt;Low (one sweep)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iterations needed&lt;/td&gt;
&lt;td&gt;Few&lt;/td&gt;
&lt;td&gt;Many&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminates when&lt;/td&gt;
&lt;td&gt;Policy stops changing&lt;/td&gt;
&lt;td&gt;Values stop changing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best when&lt;/td&gt;
&lt;td&gt;State space is small and exact&lt;/td&gt;
&lt;td&gt;State space is large or approximate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft67wzcfoyg1eg0yusm8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft67wzcfoyg1eg0yusm8x.png" alt="PI vs VI comparison" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which should you use? Small, well-defined state space where you want exactness — Policy Iteration. Large or approximate — Value Iteration.&lt;/p&gt;

&lt;p&gt;And worth flagging for later: &lt;strong&gt;almost every modern RL algorithm is spiritually a descendant of Value Iteration.&lt;/strong&gt; They update values continuously and never wait for a full evaluation to finish. Q-learning is Value Iteration with the model ripped out. DQN is Q-learning with a neural network glued on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd58xk4wtaecldkdl8ny6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd58xk4wtaecldkdl8ny6.png" alt="Convergence plot" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The curse they named but couldn't escape
&lt;/h2&gt;

&lt;p&gt;Now the bad news, and Bellman himself is the one who delivered it.&lt;/p&gt;

&lt;p&gt;Both algorithms require sweeping over &lt;strong&gt;every state in &lt;code&gt;S&lt;/code&gt;&lt;/strong&gt;. Every single one. Every iteration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4-square corridor: 4 states. Trivial.&lt;/li&gt;
&lt;li&gt;10×10 grid: 100 states. Fine.&lt;/li&gt;
&lt;li&gt;Chess: roughly 10⁴⁴ positions.&lt;/li&gt;
&lt;li&gt;Go: more legal positions than there are atoms in the observable universe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bellman named this the &lt;strong&gt;curse of dimensionality&lt;/strong&gt;, in the same 1957 book that gave us the equation. Add one variable to your state description and the state space doesn't grow — it &lt;em&gt;multiplies&lt;/em&gt;. A robot tracking position, velocity, battery, and grip status doesn't have four problems. It has (positions × velocities × battery levels × grip states) problems.&lt;/p&gt;

&lt;p&gt;And remember the poker example from earlier? Fixing the Markov violation by stuffing betting history into the state made the state space explode. That's the curse arriving in person. &lt;strong&gt;Making a problem Markov and making it small are usually opposing goals.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3xphu5bv5k6sxejgsjx.png" alt="PE vs PI" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is why RL went quiet for decades after Bellman. It wasn't that the theory was shaky. &lt;strong&gt;The theory was perfect and the computer was too small.&lt;/strong&gt; Dynamic Programming solves the &lt;em&gt;structure&lt;/em&gt; of sequential decision-making completely — it just needs a table with one row per state, and sometimes that table can't exist.&lt;/p&gt;

&lt;p&gt;The escape route — stop storing &lt;code&gt;V(s)&lt;/code&gt; in a table and start &lt;em&gt;approximating&lt;/em&gt; it with a function — wouldn't properly arrive until DeepMind's DQN in 2013. But the problem was named here, in 1957. Nearly everything between then and now is an attempt to get around it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fldvjuox3yrc4hxi0ql3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fldvjuox3yrc4hxi0ql3p.png" alt="Exponential blowup chart" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why 1957 mathematics is running inside your 2026 chatbot
&lt;/h2&gt;

&lt;p&gt;It sounds like a stretch that equations written for missile guidance underpin modern reasoning models. It isn't.&lt;/p&gt;

&lt;p&gt;When a model like &lt;strong&gt;o1&lt;/strong&gt; or &lt;strong&gt;DeepSeek-R1&lt;/strong&gt; works through a hard problem, it isn't just emitting the most likely next token. It's exploring reasoning paths, &lt;em&gt;scoring&lt;/em&gt; how promising each one looks, and abandoning the ones heading toward a dead end.&lt;/p&gt;

&lt;p&gt;Read that again with this post's vocabulary loaded:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A partial chain of reasoning is a &lt;strong&gt;state&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The next thing to write is an &lt;strong&gt;action&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;"Is this line of thinking going anywhere?" is a &lt;strong&gt;value estimate&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Backtracking out of a bad path is &lt;strong&gt;backward induction&lt;/strong&gt; — the same move Bellman made when he asked about the &lt;em&gt;last&lt;/em&gt; step instead of the first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The state space changed from grid squares to token sequences. The tables became neural networks. The core question — &lt;em&gt;how good is this situation, really?&lt;/em&gt; — is unchanged since 1957.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyhn54bk6dkq914dey11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyhn54bk6dkq914dey11.png" alt="timeline" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Six things to keep
&lt;/h2&gt;

&lt;p&gt;If every equation falls out of your head by Thursday, keep these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The world is states and actions&lt;/strong&gt; — that's an MDP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rewards define what "good" means&lt;/strong&gt; — and you're the one writing them, so be careful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value is a score for how promising the future looks from here&lt;/strong&gt; — the number Thorndike's cat never had.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Bellman Equation makes future reward flow backward&lt;/strong&gt; through states, leaving a slope you can climb.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A policy is just a rule for picking actions&lt;/strong&gt; — a lookup table, not a plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration fixes the circularity.&lt;/strong&gt; Guess, measure, improve, repeat, stop when nothing changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;If Bellman clicks, the rest of RL is refinement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu8z9j1hlh0zh5csusmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu8z9j1hlh0zh5csusmj.png" alt="Glossary" width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What's coming next
&lt;/h2&gt;

&lt;p&gt;Everything in this post rested on one assumption I flagged and then leaned on hard: &lt;strong&gt;the agent already knows &lt;code&gt;P&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt;.&lt;/strong&gt; It knows the physics. It knows the payoffs. It's not learning about the world — it's &lt;em&gt;calculating&lt;/em&gt; against a world it already has a complete map of.&lt;/p&gt;

&lt;p&gt;Real agents don't get that map.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Blog 4 — Early Heuristics and the Birth of Temporal Difference Learning (1959–1968)&lt;/strong&gt;, that assumption gets torn up. We'll meet a program that had to work out what positions were worth by &lt;em&gt;playing&lt;/em&gt;, not by computing — and we'll finally see what happens when you take Rescorla and Wagner's "learn from surprise" idea and let it fire on every single step instead of once per trial.&lt;/p&gt;

&lt;p&gt;Remember the prediction error term from the top of this post? It's about to get a job.&lt;/p&gt;

&lt;p&gt;The equation was ready. The machine was next.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next: Blog 4 — Early Heuristics and the Birth of Temporal Difference Learning (1959–1968).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Previously: Blog 1 — Biological Foundations and the Law of Effect (1898–1949) · Blog 2 — The First Machines.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reinforcementlearning</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>history</category>
    </item>
    <item>
      <title>RL 2: The first physical and computational RL machines(1948–1954)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Sat, 12 Sep 2026 05:57:48 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-2-the-first-physical-and-computational-rl-machines1948-1954-1amh</link>
      <guid>https://dev.to/mitanshgor/rl-2-the-first-physical-and-computational-rl-machines1948-1954-1amh</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick recap, if you're just arriving:&lt;/strong&gt; Blog 1 showed that every core idea in reinforcement learning was discovered by someone watching animals, not computers. Thorndike's cats taught us that learning is selection, not insight. Pavlov's dogs taught us that a signal can carry information about the future. Skinner's pigeons taught us that big behaviors are built from small rewarded steps. Hebb's neurons taught us that learning lives in the strength of a connection.&lt;/p&gt;

&lt;p&gt;Four beautiful observations. Not one of them tells you how to &lt;em&gt;build&lt;/em&gt; something that does this.&lt;/p&gt;

&lt;p&gt;This is the decade where people tried to build it anyway. What followed was ten years of beautiful, clunky, brilliant hardware — machines that stumbled through mazes, adjusted their own wiring, and learned, in the most primitive sense, from their mistakes. None of the people building them knew they were inventing Reinforcement Learning. They were just trying to make something move on its own.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Missing Link: Why "a signal predicts the future" Needed a Number
&lt;/h2&gt;

&lt;p&gt;Before we jump to the machines, one 20-second detour — because it's the cleanest bridge between Blog 1 and everything below.&lt;/p&gt;

&lt;p&gt;Pavlov noticed his dogs salivated at footsteps, before food even showed up. Nice story. But it doesn't tell you &lt;em&gt;how much&lt;/em&gt; the dog should update its expectation each time, or why the association eventually stops getting stronger.&lt;/p&gt;

&lt;p&gt;Decades later — 1972, well after everything in this post — psychologists Robert Rescorla and Allan Wagner finally wrote that down as a formula:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;α&lt;/span&gt;&lt;span class="mord mathnormal"&gt;β&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;λ&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;In plain words: &lt;em&gt;how much you learn from an event equals how surprising it was.&lt;/em&gt; &lt;code&gt;V&lt;/code&gt; is what you currently expect, &lt;code&gt;λ&lt;/code&gt; is what actually happened, and &lt;code&gt;(λ - V)&lt;/code&gt; is the surprise — the gap between prediction and reality. If a bell always predicts food, eventually there's no surprise left, and no more learning happens. That gap term is the whole engine.&lt;/p&gt;

&lt;p&gt;Why mention a 1972 psychology paper in a post about 1948–1954 engineering? Because the people you're about to meet — Wiener, Turing, Minsky, Shannon — independently backed into the exact same idea from a completely different direction: &lt;em&gt;engineering&lt;/em&gt;, not biology. None of them had read Pavlov's fine print. They just kept discovering, on their own, that intelligence seems to boil down to measuring a gap and closing it. Keep that gap-closing idea in your head — it's the thread connecting every section below.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cybernetic Spark: Wiener's Feedback Loops (1948)
&lt;/h2&gt;

&lt;p&gt;In 1948, mathematician Norbert Wiener published &lt;em&gt;Cybernetics: Or Control and Communication in the Animal and the Machine&lt;/em&gt;, and made a claim that was radical for its time: the same mathematical principle governs both living organisms and machines — &lt;strong&gt;negative feedback&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuzb0pe19qif6xzu7na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuzb0pe19qif6xzu7na.png" alt="Norbert Wiener" width="360" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Forget dogs and food for a second. Think of a thermostat. It doesn't "know" temperature in any deep sense — it just tracks one number obsessively: the gap between where it is and where it's supposed to be.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;T&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Where &lt;code&gt;T&lt;/code&gt; is the target state and &lt;code&gt;S&lt;/code&gt; is the current state. If &lt;code&gt;D ≠ 0&lt;/code&gt;, the system fires a correction to close the gap. That's it. That's the whole idea.&lt;/p&gt;

&lt;p&gt;This is exactly the Rescorla-Wagner gap from above, just wearing an engineer's clothes instead of a psychologist's. &lt;code&gt;D&lt;/code&gt; here is the direct ancestor of the &lt;strong&gt;Temporal Difference (TD) error&lt;/strong&gt; you'll see in modern RL — the signal that tells an agent "something's off, adjust." Every gradient update in every deep RL system running today is, underneath the math, a Wiener-style error minimization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsiow833y4mu41qyc87l9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsiow833y4mu41qyc87l9.png" alt="thermostat vs organism comparison" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Wiener's punchline:&lt;/strong&gt; Intelligence isn't magic. It's error minimization on a loop. If you can define a goal and measure your distance from it, a machine can "learn" to close that distance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvq6yd134hkpydroyxd6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvq6yd134hkpydroyxd6.png" alt="Cybernetics Diagram" width="768" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So Wiener gave the field a &lt;em&gt;drive&lt;/em&gt; — a reason to move, a number to chase to zero. But a drive isn't a mechanism. It doesn't tell you what happens inside the machine when it's wrong versus when it's right. That's exactly what Alan Turing was working out, in the very same year, from a completely different angle.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Turing Blueprint: Pain, Pleasure, and the First Neural Network on Paper (1948)
&lt;/h2&gt;

&lt;p&gt;Turing's 1948 paper &lt;em&gt;Intelligent Machinery&lt;/em&gt; introduced the &lt;strong&gt;P-type (Pain-type) Unorganized Machine&lt;/strong&gt;, and reading it today feels like finding the first design document for a neural network, forty years too early.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbcg2qdg8dv83jnwnck8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbcg2qdg8dv83jnwnck8.png" alt="Alan Turing" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Turing's argument was blunt: a human infant's cortex is mostly a random, disorganized network that only becomes useful through experience. So why not build the machine equivalent? He proposed a network built from &lt;strong&gt;NAND gates&lt;/strong&gt; — think of these as the smallest possible decision units, each taking two inputs and spitting out one output based on a simple rule. Each gate could sit in one of two internal "configuration states," and that state is what determined how the gate behaved.&lt;/p&gt;

&lt;p&gt;The learning happened through two signals, and this is the part that matters:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pain&lt;/strong&gt; — when the machine got something wrong, the gates that had just fired got scrambled at random:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathit mtight"&gt;next&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathit"&gt;RandomSample&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Pleasure&lt;/strong&gt; — when the machine got something right, those same configurations froze in place. No more random reshuffling:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;Δ&lt;/span&gt;&lt;span class="mord mathnormal"&gt;C&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;Pleasure&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;So: wrong answer, shake things up. Right answer, lock it in. It's almost embarrassingly simple — which is exactly why it's important.&lt;/p&gt;

&lt;p&gt;Turing also spotted the obvious problem immediately: pure random shuffling doesn't scale. If a machine has &lt;code&gt;n&lt;/code&gt; units, each with &lt;code&gt;k&lt;/code&gt; possible states, the number of configurations to search through is &lt;code&gt;k^n&lt;/code&gt; — a number that explodes into uselessness almost immediately, even for tiny machines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01nodr2ttwo9rz0ys009.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01nodr2ttwo9rz0ys009.png" alt="search space explosion" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;His fix: bring in a &lt;strong&gt;teacher&lt;/strong&gt;. Instead of letting the machine flail randomly forever, a teacher hands out Pleasure signals early to nudge it toward useful sub-behaviors, and &lt;em&gt;then&lt;/em&gt; Pain prunes away the remaining mistakes. That's not just a clever patch — it's the seed of &lt;strong&gt;Supervised Fine-Tuning (SFT)&lt;/strong&gt; and &lt;strong&gt;Imitation Learning&lt;/strong&gt;, ideas that wouldn't get their modern names for another fifty-plus years. Turing had quietly moved the burden of "being smart" off the programmer's shoulders and onto the environment's.&lt;/p&gt;

&lt;p&gt;His paper sat mostly unread for decades. But look at the shape of it: a randomly wired network, shaped over time by reward and punishment, converging on useful behavior. Every RLHF pipeline running behind a modern chatbot is, structurally, still running Turing's 1948 loop.&lt;/p&gt;

&lt;p&gt;Wiener gave us the &lt;em&gt;why&lt;/em&gt; — close the gap. Turing gave us the &lt;em&gt;what happens inside&lt;/em&gt; — freeze on success, scramble on failure. What nobody had shown yet was a machine that could do this outside of a chalkboard, with actual physical parts that changed themselves. That's where Marvin Minsky comes in.&lt;/p&gt;




&lt;h2&gt;
  
  
  Minsky's SNARC: The First Machine That Rewired Itself (1951–1954)
&lt;/h2&gt;

&lt;p&gt;While Turing's ideas stayed on paper, Marvin Minsky and his Princeton colleague Dean Edmonds went to the workshop and actually built something.&lt;/p&gt;

&lt;p&gt;In 1951, they built the &lt;strong&gt;SNARC — Stochastic Neural Analog Reinforcement Calculator&lt;/strong&gt; — the first machine to physically implement Hebbian learning (remember Blog 1: neurons that fire together, wire together) combined with reinforcement, in real hardware. Minsky later wrote it up in his 1954 thesis.&lt;/p&gt;

&lt;p&gt;The SNARC simulated a rat finding its way through a maze using &lt;strong&gt;40 artificial synapses&lt;/strong&gt;. Each "synapse" was a vacuum tube paired with a &lt;strong&gt;potentiometer&lt;/strong&gt; — picture a volume knob, a simple dial that changes how much resistance flows through a circuit. That dial's position &lt;em&gt;was&lt;/em&gt; the connection's strength, standing in for what we'd now call a "weight."&lt;/p&gt;

&lt;p&gt;Here's the learning loop, in plain terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A signal representing the "rat" travels through the network, picking a path.&lt;/li&gt;
&lt;li&gt;If that path leads to reward, the potentiometers ("volume knobs") along that path get turned to &lt;em&gt;lower&lt;/em&gt; resistance — meaning that path becomes electrically easier to travel next time.&lt;/li&gt;
&lt;li&gt;If the path leads nowhere, those knobs stay put or drift the other way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuydwodumc7cadtgqsmlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuydwodumc7cadtgqsmlh.png" alt="mouse" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice what's happening here: this is &lt;strong&gt;credit assignment&lt;/strong&gt;, done with actual electricity. The machine had no rule anywhere that said "this specific connection caused the reward." It used the reward signal traveling backward through whichever path was active to figure out which knobs to turn. That's structurally the same job that backpropagation does in a modern neural network — just with copper and vacuum tubes instead of calculus.&lt;/p&gt;

&lt;p&gt;The SNARC couldn't scale — 40 synapses is barely a network by today's standards, and analog parts drift and degrade over time. But it proved something that had never been physically shown before: &lt;strong&gt;a machine can change its own internal wiring in response to reward, with no one programming the change directly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That single idea — connections that adjust themselves because of reward — is the founding premise of every neural network trained with RL today.&lt;/p&gt;

&lt;p&gt;So now we've got a drive (Wiener), a mechanism (Turing), and proof that self-adjusting hardware works (Minsky). One year later, Claude Shannon showed what happens when you point that same idea at something a person can actually watch move.&lt;/p&gt;




&lt;h2&gt;
  
  
  Claude Shannon's Theseus: Learning You Can See (1952)
&lt;/h2&gt;

&lt;p&gt;Shannon's contribution was the most tangible of the whole decade. In 1952, he built &lt;strong&gt;Theseus&lt;/strong&gt; — a copper mouse that could navigate a 5×5 maze, controlled by a cabinet of 75 telephone relays sitting underneath.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpu0uxf58s9y1oodpsvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpu0uxf58s9y1oodpsvk.png" alt="Claude Shannon" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the trick: the mouse itself had no brain. The relays — think of a relay as a mechanical switch that can remember whether it's "on" or "off" — &lt;em&gt;were&lt;/em&gt; the brain. Each of the 25 cells in the maze corresponded to a relay setup that remembered which directions had already failed from that spot. Hit a wall, and the relay for that direction-at-that-position flipped off, so the mouse tried something else next time. Find a working path, and those relay settings locked in for good.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m57s6tvpgxnkl40yipq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m57s6tvpgxnkl40yipq.png" alt="Shannon Maze Environment" width="729" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The payoff: drop Theseus anywhere in a maze it had already solved, and it walked straight to the goal, no hesitation. Drop it somewhere new, and it explored from scratch — then remembered &lt;em&gt;that&lt;/em&gt; too.&lt;/p&gt;

&lt;p&gt;What Shannon had actually built was a physical &lt;strong&gt;lookup table&lt;/strong&gt;: a direct map from state (position in the maze) to action (which way to go), stored as the mechanical position of 75 relays. This is the hardware great-grandparent of what's now called a Q-table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvty8q58nbk0v391cspa7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvty8q58nbk0v391cspa7.png" alt="relay vs plain qtable" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the genuinely clever part was the &lt;strong&gt;"anti-neurotic" circuit&lt;/strong&gt;. Shannon noticed that a strategy based purely on "eliminate what failed" could trap the mouse in an infinite loop — try North, fail, try East, fail, loop back to North forever, repeat. His fix: a circuit that detected this looping behavior and injected a random direction change to break it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nvbe3da87tqi3yegh7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nvbe3da87tqi3yegh7f.png" alt="break loop" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is, as far as anyone can tell, the first deliberate hardware solution to &lt;strong&gt;exploration vs. exploitation&lt;/strong&gt; — the tension that sits at the center of nearly every RL algorithm ever written. In plain terms: should the mouse keep using the move it already knows works (&lt;em&gt;exploit&lt;/em&gt;), or try something new in case there's a better option (&lt;em&gt;explore&lt;/em&gt;)? Shannon's answer was a random kick when stuck. Modern RL answers with names like epsilon-greedy (occasionally pick a random action on purpose) or entropy bonuses (reward the agent slightly for staying unpredictable). Same problem, seventy years of better tools.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Theseus proved something important: "learning" could be reduced entirely to hardware state changes. No probability distributions, no gradients — just relays flipping. Intelligence as a lookup table.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frg4gtpm2i20cio1ns4rh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frg4gtpm2i20cio1ns4rh.png" alt="hitting walls, then the " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bridge (1954–1957): From Wires to Equations
&lt;/h2&gt;

&lt;p&gt;By the mid-1950s, the hardware approach was hitting a wall. Shannon's mouse could solve one specific maze. Minsky's SNARC topped out at 40 synapses. Turing's ideas mostly lived on paper. Every one of these machines was an impressive, custom-built solution to one specific problem — and none of them generalized.&lt;/p&gt;

&lt;p&gt;Richard Bellman, among others, got impatient with that. Building a maze-solving mouse was a great parlor trick, but it wasn't a &lt;em&gt;theory&lt;/em&gt;. What he wanted was a general rule — something that could handle any problem made of a long chain of decisions, no matter what the environment looked like underneath.&lt;/p&gt;

&lt;p&gt;The question shifted from &lt;em&gt;"can we make this specific thing work?"&lt;/em&gt; to &lt;em&gt;"can we prove the mathematically best way to act, in general?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bellman's answer became the &lt;strong&gt;Principle of Optimality&lt;/strong&gt; and the &lt;strong&gt;Bellman Equation&lt;/strong&gt;: the idea that the value of being in a state is just the immediate reward, plus the (slightly discounted) value of wherever you end up next. He took the mechanical "vibes" of the SNARC and Theseus and translated them into a single recursive formula — one equation that compresses an agent's entire future into a present-tense number.&lt;/p&gt;

&lt;p&gt;That equation, and the computational nightmare it revealed (Bellman's own term for it: the &lt;strong&gt;Curse of Dimensionality&lt;/strong&gt;), is where Blog 3 picks up. For now, the point is simpler: after a decade of wiring things together by hand, the field realized it needed math to go any further.&lt;/p&gt;

&lt;p&gt;The wires were beautiful. But equations scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Decade in One Frame
&lt;/h2&gt;

&lt;p&gt;Zooming out, here's what this era actually built — not a summary, a thesis:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wiener (1948)&lt;/strong&gt; gave learning a &lt;em&gt;drive&lt;/em&gt;: minimize the gap on a feedback loop.&lt;br&gt;
&lt;strong&gt;Turing (1948)&lt;/strong&gt; gave learning a &lt;em&gt;mechanism&lt;/em&gt;: reward freezes, punishment randomizes.&lt;br&gt;
&lt;strong&gt;Minsky (1951/54)&lt;/strong&gt; gave learning &lt;em&gt;physical weight&lt;/em&gt;: the first adjustable synapses that existed as hardware, not theory.&lt;br&gt;
&lt;strong&gt;Shannon (1952)&lt;/strong&gt; gave learning &lt;em&gt;memory&lt;/em&gt;: state-action mappings stored in the physical position of relays.&lt;br&gt;
&lt;strong&gt;Bellman (1957)&lt;/strong&gt; gave learning &lt;em&gt;math&lt;/em&gt;: a recursive formula that would eventually unify everything above it — that's Blog 3.&lt;/p&gt;

&lt;p&gt;In under a decade, "learning" went from a biological observation about cats and pigeons to a wired, probabilistic, physically real process you could point to on a workbench. The machines were small, fragile, and each one could only do exactly one thing. But the ideas inside them were load-bearing — every one of them is still holding up the RL systems built today.&lt;/p&gt;

</description>
      <category>rl</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
    <item>
      <title>RL 1: Biological foundations and the "Law of Effect" (1898– 1949)</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Wed, 02 Sep 2026 22:58:37 +0000</pubDate>
      <link>https://dev.to/mitanshgor/rl-1-biological-foundations-and-the-law-of-effect-1898-1949-1a9f</link>
      <guid>https://dev.to/mitanshgor/rl-1-biological-foundations-and-the-law-of-effect-1898-1949-1a9f</guid>
      <description>&lt;p&gt;Before GPUs. Before neural networks. Before transistors were even a rumor.&lt;/p&gt;

&lt;p&gt;There was a hungry cat in a wooden crate, trying to get to a piece of fish.&lt;/p&gt;

&lt;p&gt;The main character of this era isn't an engineer. It's a loose group of psychologists — some of whom actively disliked each other's ideas — poking at animals to answer one question: &lt;em&gt;why do living things do the things they do?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;They never wrote a line of code. They were not trying to build AI. And yet, in the fifty years between 1898 and 1949, they collectively reverse-engineered the core loop that every modern reinforcement learning system still runs on.&lt;/p&gt;

&lt;p&gt;This post is that story. No math yet — I promise. Just the loop, and the four people who found its pieces.&lt;/p&gt;




&lt;h2&gt;
  
  
  First, the thing we're building
&lt;/h2&gt;

&lt;p&gt;Let me give you the shape of the answer before the story, so you know what you're collecting.&lt;/p&gt;

&lt;p&gt;Reinforcement learning describes any system that learns by &lt;strong&gt;doing stuff and seeing what happens.&lt;/strong&gt; That's it. Not by being shown correct answers — by trying, failing, and adjusting.&lt;/p&gt;

&lt;p&gt;We'll call the learner the &lt;strong&gt;agent&lt;/strong&gt; (the cat, the rat, the robot, the model). Everything outside it is the &lt;strong&gt;environment&lt;/strong&gt; (the box, the room, the game). The loop runs like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbm95lgy9r5kbc7tyi1fg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbm95lgy9r5kbc7tyi1fg.png" alt="RL" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent observes its &lt;strong&gt;state&lt;/strong&gt; — the situation it's currently in.&lt;/li&gt;
&lt;li&gt;It picks an &lt;strong&gt;action.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The environment responds with a &lt;strong&gt;reward&lt;/strong&gt; — a number saying "that was good" or "that was bad."&lt;/li&gt;
&lt;li&gt;The agent lands in a new state, and the loop repeats.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two more, and they're the ones that do the heavy lifting later.&lt;/p&gt;

&lt;p&gt;The agent needs a &lt;strong&gt;policy&lt;/strong&gt;: a strategy for choosing actions. Not a fixed script — a rule of thumb that says &lt;em&gt;in this kind of situation, do this kind of thing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And it needs a sense of &lt;strong&gt;value&lt;/strong&gt;: how good a state is, based not on the reward sitting in it right now, but on everything it tends to lead to. An empty hallway is worth nothing on its own. An empty hallway &lt;em&gt;with the kitchen at the end of it&lt;/em&gt; is worth quite a lot.&lt;/p&gt;

&lt;p&gt;Six words: &lt;strong&gt;agent, state, action, reward, policy, value.&lt;/strong&gt; Every single one of them was discovered by someone studying animals, decades before anyone could program a computer.&lt;/p&gt;

&lt;p&gt;Let's go get them.&lt;/p&gt;




&lt;h2&gt;
  
  
  1898 — Thorndike's Cats and the Law of Effect
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm8xra1vrxrrankczn0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm8xra1vrxrrankczn0l.png" alt="Edward Thorndike" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1898, a graduate student named Edward Thorndike was annoyed.&lt;/p&gt;

&lt;p&gt;The animal literature of his day was full of charming anecdotes — dogs who &lt;em&gt;understood&lt;/em&gt; latches, cats who &lt;em&gt;figured out&lt;/em&gt; doorknobs. Thorndike's suspicion was that people were flattering their pets. Animals weren't reasoning. They were doing something else, and nobody had bothered to measure it.&lt;/p&gt;

&lt;p&gt;So he built the &lt;a href="https://www.appstate.edu/~steelekm/classes/psy5300/Documents/chance-72-433.pdf" rel="noopener noreferrer"&gt;puzzle box&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The setup is almost comically simple. A hungry cat goes in a small wooden crate. The door opens only if the cat pulls a loop of string, or presses a lever, or steps on a pedal. A piece of fish sits outside, in plain view. Then Thorndike started a stopwatch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa8weof0r3zhvb75exe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa8weof0r3zhvb75exe7.png" alt="Thorndike's puzzle box environment" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial one is chaos.&lt;/strong&gt; The cat claws the bars. It shoves its paws through every gap. It bites things, yowls, thrashes at anything loose. After a few minutes of pure flailing, it hits the lever &lt;em&gt;by accident.&lt;/em&gt; The door swings open. Fish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial two:&lt;/strong&gt; slightly less flailing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trial twenty:&lt;/strong&gt; the cat walks in, hits the lever, and strolls out.&lt;/p&gt;

&lt;p&gt;Here's what Thorndike noticed, and it's the part that matters: &lt;strong&gt;there was never a lightbulb moment.&lt;/strong&gt; No trial where the cat suddenly &lt;em&gt;got it.&lt;/em&gt; If cats were reasoning about levers, you'd expect the escape time to fall off a cliff — one long trial, then instantly fast ones. Instead, when he plotted escape time against trial number, he got a slow, noisy, gradual curve. The useless behaviors quietly faded. The useful one got faster.&lt;/p&gt;

&lt;p&gt;That curve is the first real evidence in this story. Learning wasn't insight. It was &lt;strong&gt;selection&lt;/strong&gt; — good behaviors surviving, bad ones dying off.&lt;/p&gt;

&lt;p&gt;Thorndike wrote it up as the &lt;strong&gt;Law of Effect&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If an action is followed by a satisfying state of affairs, the bond between that situation and that action is strengthened. If followed by discomfort, it is weakened.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Read that again with our vocabulary. &lt;em&gt;Situation&lt;/em&gt; is the &lt;strong&gt;state&lt;/strong&gt;. &lt;em&gt;Action&lt;/em&gt; is the &lt;strong&gt;action&lt;/strong&gt;. &lt;em&gt;Satisfying&lt;/em&gt; is the &lt;strong&gt;reward&lt;/strong&gt;. &lt;em&gt;Bond strengthened&lt;/em&gt; is the &lt;strong&gt;policy update&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thorndike, in 1898, wrote pseudocode for a policy gradient. He just used the word "bond."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; trial-and-error learning. Rewards make actions more likely. Learning is gradual, not sudden.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's missing
&lt;/h3&gt;

&lt;p&gt;Thorndike's cat only learns &lt;em&gt;after&lt;/em&gt; it gets the fish. The reward does all the teaching.&lt;/p&gt;

&lt;p&gt;But watch a real animal for five minutes and you'll notice it reacting to things that aren't rewards at all. Your dog loses its mind at the sound of a cupboard opening. Nothing has been eaten yet. The cupboard &lt;em&gt;predicts&lt;/em&gt; food.&lt;/p&gt;

&lt;p&gt;Thorndike had no account of that. Rewards were where his story started and ended.&lt;/p&gt;

&lt;p&gt;The person who noticed the signal was, characteristically, not looking for it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 1900s–1920s — Pavlov and the Problem of Prediction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrb3lotitr11lo46umfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrb3lotitr11lo46umfx.png" alt="Ivan Pavlov" width="800" height="1019"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ivan Pavlov was a Russian physiologist studying digestion. He won a Nobel Prize for it in 1904. He was, by most accounts, mildly irritated that history remembers him for the dogs.&lt;/p&gt;

&lt;p&gt;His actual research required measuring saliva. And his dogs kept ruining the measurements by salivating &lt;strong&gt;early&lt;/strong&gt; — at the sight of the lab assistant who usually brought food, at the sound of footsteps in the corridor. Before any food existed.&lt;/p&gt;

&lt;p&gt;Most researchers would call that noise and try to control for it. Pavlov called it the experiment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9me8tgsxmv8vn7qrwgf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9me8tgsxmv8vn7qrwgf1.png" alt="Pavlov's dog experiment" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;He ran it systematically. Present a neutral signal — a metronome, a buzzer, a light, a tone — then deliver food, a second or two later. Repeat.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Quick myth-correction, since it costs one sentence: the famous bell is mostly folklore. Pavlov's lab notes lean heavily on metronomes, buzzers, and tuning forks. The bell survived because it's easier to draw.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After enough pairings, the signal alone made the dogs salivate. Nothing about the food had changed. What changed was that the dog had learned &lt;strong&gt;the signal carries information about the future.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the second piece, and it's a big one. Thorndike's cat learned &lt;em&gt;what to do.&lt;/em&gt; Pavlov's dog learned &lt;em&gt;what's coming.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In RL terms, that's &lt;strong&gt;value&lt;/strong&gt;. The value of a state is roughly: &lt;em&gt;how much good stuff do I expect from here on out?&lt;/em&gt; A metronome that reliably precedes food is a high-value state — not because a metronome is nutritious, but because of what tends to follow it.&lt;/p&gt;

&lt;p&gt;You do this constantly. The smell of coffee is not caffeine. Your inbox badge is not the email. A green light is not arriving anywhere. Every one of these is a state you've assigned value to, purely because of what historically came next.&lt;/p&gt;

&lt;p&gt;And this is why RL agents can learn anything at all in sparse environments. A chess engine that only felt reward at checkmate would learn approximately nothing — the signal is 60 moves away from most of the decisions that caused it. What it actually learns is to value &lt;em&gt;positions&lt;/em&gt;: this pawn structure tends to precede winning. That's a metronome.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; states have value. Value comes from &lt;em&gt;prediction&lt;/em&gt;, not from the reward itself.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's still missing
&lt;/h3&gt;

&lt;p&gt;Pavlov's dogs were passive. They sat in a harness and predicted. The dog's salivation doesn't make the food arrive any sooner.&lt;/p&gt;

&lt;p&gt;So now we have two halves of an agent and no glue:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Thorndike's cat&lt;/th&gt;
&lt;th&gt;Pavlov's dog&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Learns&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;which actions pay off&lt;/td&gt;
&lt;td&gt;which signals predict payoff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Can it act?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Can it anticipate?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A real agent needs both — and it needs someone to make this a controllable science rather than a collection of observations. That took a genuine control freak.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 1930s–50s — Skinner Turns Behavior Into Engineering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwal2v9jj5pw68zrj5oa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwal2v9jj5pw68zrj5oa.png" alt="B.F. Skinner" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;B.F. Skinner's question was different from everyone before him. Not "how do animals learn?" but: &lt;strong&gt;"how precisely can I control what an animal learns?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;His tool was the operant conditioning chamber — the Skinner Box. A rat inside can press a bar. A pigeon can peck a disc. Food is dispensed on rules Skinner sets. Simple inputs, measurable outputs, and — critically — the animal &lt;em&gt;stays in the box.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oszf4z6acztkuf32c73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oszf4z6acztkuf32c73.png" alt="Rat in a Skinner box" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That last detail seems minor and isn't. Thorndike's cats escaped, which meant one trial, then a reset by hand. Skinner's animals could run thousands of trials in an afternoon, uninterrupted. He'd built the first high-throughput training environment. Every RL researcher who has ever run a simulator overnight is doing the same thing.&lt;/p&gt;

&lt;p&gt;Two of his findings matter for us.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding 1: Unpredictable rewards are the stickiest
&lt;/h3&gt;

&lt;p&gt;Skinner varied &lt;em&gt;when&lt;/em&gt; reward arrived — every press, every fifth press, every fifth press &lt;em&gt;on average.&lt;/em&gt; These are &lt;strong&gt;schedules of reinforcement.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The counterintuitive result: &lt;strong&gt;variable&lt;/strong&gt; reward — where the animal can't predict which press pays — produced behavior that was hardest to extinguish. Reward a pigeon every single time, then stop, and it gives up quickly. Reward it unpredictably, then stop, and it keeps going for a remarkably long time.&lt;/p&gt;

&lt;p&gt;Slot machines run on this. So do infinite-scroll feeds. Skinner found the exploit in the 1950s; the attention economy just productized it.&lt;/p&gt;

&lt;p&gt;For us, the useful version is that reward &lt;em&gt;structure&lt;/em&gt; is a design decision with enormous consequences. Which sets up an entire genre of modern RL failure — agents that learn the reward signal instead of the task, in ways nobody intended. We'll spend real time there in a later post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding 2: You can build complex behavior out of crumbs
&lt;/h3&gt;

&lt;p&gt;The bigger idea is &lt;strong&gt;shaping.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Skinner taught pigeons to play a passable game of table tennis. Not by waiting for a pigeon to spontaneously play table tennis — you'd wait forever. He rewarded &lt;em&gt;incremental steps.&lt;/em&gt; First, reward the bird for merely facing the table. Once that's reliable, stop rewarding it and only pay for approaching the ball. Then only for contact. Then only for direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/shorts/RPJyKSmH9WM?feature=share" rel="noopener noreferrer"&gt;https://www.youtube.com/shorts/RPJyKSmH9WM?feature=share&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You are moving the goalposts on purpose, in small enough increments that the animal never falls off the curve.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;reward shaping&lt;/strong&gt;, and it's how we train robots today. A robot arm rewarded only for "successfully assembled the part" will flail randomly forever, because the odds of stumbling into success by accident are effectively zero. So we hand it crumbs: reward for moving toward the part, then for gripping it, then for lifting. Same ladder. Different species.&lt;/p&gt;

&lt;p&gt;And the strategy the animal ends up with — &lt;em&gt;in this situation, do this&lt;/em&gt; — is exactly what we called a &lt;strong&gt;policy&lt;/strong&gt; at the top of this post. Skinner spent thirty years training policies. He just did it with pigeons and a food dispenser instead of gradients and a GPU.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; policies can be &lt;em&gt;trained&lt;/em&gt;, not just observed. Reward timing and reward structure change everything.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  But something's still missing
&lt;/h3&gt;

&lt;p&gt;We now have a full behavioral picture: act, predict, get shaped, improve.&lt;/p&gt;

&lt;p&gt;Every bit of it is described from the outside. Skinner was deliberate about this — he treated the mind as a black box and argued you should only ever talk about observable behavior. Which is scientifically disciplined and completely useless if you want to &lt;em&gt;build&lt;/em&gt; one.&lt;/p&gt;

&lt;p&gt;Because if you're going to build this thing, you need to answer a question Skinner refused to ask: &lt;strong&gt;where does the learning physically live?&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1949 — Hebb Finds the Storage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpq0oxiztlxp2o9uy8z1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpq0oxiztlxp2o9uy8z1.png" alt="Donald Hebb" width="491" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Donald Hebb, a Canadian psychologist, published &lt;em&gt;The Organization of Behavior&lt;/em&gt; in 1949 and proposed a mechanism so simple it fits in a sentence.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If neuron A repeatedly takes part in firing neuron B, some growth process or metabolic change takes place in both cells such that A's efficiency in firing B is increased.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's &lt;strong&gt;Hebb's Rule&lt;/strong&gt;, and the pop version is stickier: &lt;strong&gt;neurons that fire together, wire together.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ei581ewgfx0kd2zqhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ei581ewgfx0kd2zqhk.png" alt="Hebb's rule: neuron A firing neuron B" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two neurons active at the same time? The connection between them — the &lt;strong&gt;synapse&lt;/strong&gt; — physically strengthens. Next time, A triggers B more easily. Do it enough and the path becomes a highway.&lt;/p&gt;

&lt;p&gt;Run Thorndike's cat through this. The cat sees the lever (a pattern of neurons firing) and presses it (another pattern firing). They're active together. Their connection thickens. A hundred trials later, seeing the lever &lt;em&gt;is&lt;/em&gt; pressing the lever — there's a paved road between them.&lt;/p&gt;

&lt;p&gt;That's a habit, described in hardware.&lt;/p&gt;

&lt;p&gt;And this is where artificial neural networks come from. In a network, the connection strength between two artificial neurons is a number called a &lt;strong&gt;weight.&lt;/strong&gt; Learning means adjusting weights so that useful inputs reliably produce useful outputs. Hebb is the reason "learning = changing connection strengths" is the default assumption in the entire field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One important correction, because this gets flattened a lot:&lt;/strong&gt; Hebb's rule is &lt;em&gt;not&lt;/em&gt; backpropagation, and the difference is worth thirty seconds.&lt;/p&gt;

&lt;p&gt;Hebb's rule is &lt;strong&gt;local&lt;/strong&gt;. A synapse strengthens based only on what its own two neurons are doing right now. No supervisor, no error signal, nobody keeping score.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backpropagation&lt;/strong&gt; — the algorithm that actually trains modern networks — is &lt;strong&gt;global and error-driven&lt;/strong&gt;. It compares the network's output to a desired output, computes how wrong it was, and pushes that error signal backward through every layer, adjusting each weight by how much it contributed to the mistake. Every weight update depends on information from far away in the network.&lt;/p&gt;

&lt;p&gt;These are genuinely different mechanisms. In fact, the gap between them is one of the liveliest open arguments in neuroscience: brains clearly don't run backprop — there's no known biological machinery for shipping a precise error signal backward across a network — yet backprop works spectacularly well. Whether the brain approximates something like it, or does something else entirely, is unresolved.&lt;/p&gt;

&lt;p&gt;So the honest lineage is: &lt;strong&gt;Hebb gave us the idea that memory lives in connection strengths.&lt;/strong&gt; Backprop is a much later, mathematically-driven answer to &lt;em&gt;how to update&lt;/em&gt; those strengths. Same neighborhood, different building.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎒 &lt;strong&gt;In the backpack:&lt;/strong&gt; learning is stored in connection weights. Local, physical, incremental.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Where that leaves us in 1949
&lt;/h2&gt;

&lt;p&gt;Fifty-one years, four researchers, and the loop is complete:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Idea&lt;/th&gt;
&lt;th&gt;From&lt;/th&gt;
&lt;th&gt;What it becomes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rewards strengthen the actions that earned them&lt;/td&gt;
&lt;td&gt;Thorndike, 1898&lt;/td&gt;
&lt;td&gt;the reward signal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Signals predict future reward&lt;/td&gt;
&lt;td&gt;Pavlov, 1900s&lt;/td&gt;
&lt;td&gt;value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Behavior can be sculpted step by step&lt;/td&gt;
&lt;td&gt;Skinner, 1930s–50s&lt;/td&gt;
&lt;td&gt;policies, reward shaping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning is stored in connection strengths&lt;/td&gt;
&lt;td&gt;Hebb, 1949&lt;/td&gt;
&lt;td&gt;weights&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read that table top to bottom and you have a specification. Something that acts, predicts, gets shaped by consequences, and stores what it learned in the strength of its connections.&lt;/p&gt;

&lt;p&gt;Nobody had built it. Nobody could — the ideas were all written in the language of biology, describing wet tissue that nobody could manufacture.&lt;/p&gt;

&lt;p&gt;But 1949 is the year that stops being true. The war had just produced digital computers. A new field called &lt;strong&gt;cybernetics&lt;/strong&gt; was arguing that control and feedback worked the same way in animals and machines, and that the distinction was less fundamental than everyone assumed.&lt;/p&gt;

&lt;p&gt;For the first time, people had a spec for learning &lt;em&gt;and&lt;/em&gt; a machine to run it on.&lt;/p&gt;




&lt;h2&gt;
  
  
  One thing they all got wrong
&lt;/h2&gt;

&lt;p&gt;Before we leave the psychologists, here's the crack in the foundation — worth holding onto, because it takes another twenty years to fix.&lt;/p&gt;

&lt;p&gt;Every idea above says learning happens when things &lt;strong&gt;co-occur.&lt;/strong&gt; Metronome and food together → learn. Lever and fish together → learn. Neurons active together → wire together.&lt;/p&gt;

&lt;p&gt;But co-occurrence can't be the whole story:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your alarm has gone off at 7am every day for a year.&lt;/strong&gt; By the co-occurrence rule, this morning should have strengthened that association a little further, same as every other morning. It didn't. You learned it in the first week and then stopped — even though the pairing kept happening, perfectly, hundreds more times.&lt;/p&gt;

&lt;p&gt;So what switches learning &lt;em&gt;off&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Nobody in this post can answer that. The answer arrives in 1972, from a pair of psychologists still studying rats, and when it does it turns out to be the single most important equation in this entire series. We'll get there.&lt;/p&gt;




&lt;h2&gt;
  
  
  Next up
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;RL #2 — Cybernetics and Early Machines (1948–1954).&lt;/strong&gt; The first people to actually build this thing. Alan Turing sketching a "pleasure-pain system" in 1948. Claude Shannon's Theseus, a mechanical mouse that learned a maze by trial and error and could remember it. And Marvin Minsky wiring together the SNARC — 40 vacuum tubes, motors, and a clutch, arguably the first machine that learned by reinforcement.&lt;/p&gt;

&lt;p&gt;The cats gave us the algorithm. Now watch people try to solder it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you spot an error or think I've oversimplified something, drop it in the comments — I'd rather fix it than have it sit there.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rl</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>Reinforcement Learning Series</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Wed, 19 Aug 2026 18:40:39 +0000</pubDate>
      <link>https://dev.to/mitanshgor/reinforcement-learning-series-4m6j</link>
      <guid>https://dev.to/mitanshgor/reinforcement-learning-series-4m6j</guid>
      <description>&lt;p&gt;I created this series to make that steep learning curve far less daunting for you. My goal is to trace the evolution of RL chronologically—from its roots in early psychology and physical mechanical machines to digital binary systems and modern mathematical breakthroughs. By breaking down complex concepts with clear visual guides, graphics, and real-world analogies, I hope to demystify RL and give back to the community that inspired me. Let’s dive in!&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 1: The Psychological Seeds (1898–1949)
&lt;/h3&gt;

&lt;p&gt;This entry explores the &lt;strong&gt;Law of Effect&lt;/strong&gt; (1911), where Edward Thorndike established that actions followed by satisfaction are strengthened. It also covers Ivan Pavlov’s formal definition of &lt;strong&gt;reinforcement&lt;/strong&gt; (1927) and Donald Hebb’s 1949 hypothesis that "neurons that fire together, wire together," laying the groundwork for neural learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 2: Cybernetics and Early Machines (1948–1954)
&lt;/h3&gt;

&lt;p&gt;This blog details the first computational investigations, including &lt;strong&gt;Alan Turing’s&lt;/strong&gt; "pleasure-pain system" (1948) and Marvin Minsky’s construction of &lt;strong&gt;SNARCs&lt;/strong&gt; (1954), the first analog neural-network reinforcement calculators. It also highlights &lt;strong&gt;Claude Shannon’s&lt;/strong&gt; 1952 demonstration of "Theseus," a maze-running mouse that used trial and error to "remember" paths.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 3: The Mathematical Framework (1950s–1960s)
&lt;/h3&gt;

&lt;p&gt;This post focuses on &lt;strong&gt;Richard Bellman’s&lt;/strong&gt; development of &lt;strong&gt;Dynamic Programming&lt;/strong&gt; and the Bellman Equation (1957), which provided the formal tools for solving optimal control problems. It also introduces &lt;strong&gt;Markov Decision Processes (MDPs)&lt;/strong&gt; and Ron Howard’s &lt;strong&gt;policy iteration&lt;/strong&gt; method (1960), which are the bedrock of modern RL theory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 4: Early Heuristics and Checkers (1959–1968)
&lt;/h3&gt;

&lt;p&gt;This entry discusses &lt;strong&gt;Arthur Samuel’s&lt;/strong&gt; celebrated checkers program (1959), which was the first to implement &lt;strong&gt;temporal-difference (TD)&lt;/strong&gt; ideas by using board evaluation differences to modify earlier positions. It also details Donald Michie’s &lt;strong&gt;MENACE&lt;/strong&gt; (1961), a physical "matchbox" engine that learned to play Noughts and Crosses through reinforcement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 5: The Birth of Learning Automata (1961–1974)
&lt;/h3&gt;

&lt;p&gt;This blog examines the Soviet lineage of RL, specifically &lt;strong&gt;Mikhail Tsetlin’s&lt;/strong&gt; work on "learning automata" (1961), which were finite-state machines that updated action probabilities based on stochastic environmental feedback. It traces how this research was later systematised by Narendra and Thathachar in 1974.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 6: The "Hedonistic" Revival (1972–1980)
&lt;/h3&gt;

&lt;p&gt;This post covers &lt;strong&gt;Harry Klopf’s&lt;/strong&gt; pivotal role in reviving the trial-and-error thread by proposing the &lt;strong&gt;"hedonistic neuron"&lt;/strong&gt; (1972), which argued that neurons act as pleasure-seeking units. It also explores Paul Werbos’s 1974 thesis, which was the first to describe &lt;strong&gt;backpropagation&lt;/strong&gt; in the context of "Adaptive Dynamic Programming".&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 7: The Sutton and Barto Foundation (1981–1984)
&lt;/h3&gt;

&lt;p&gt;This blog highlights the formalisation of modern RL, beginning with &lt;strong&gt;Sutton and Barto’s&lt;/strong&gt; 1981 model of classical conditioning. It details the invention of the &lt;strong&gt;Actor-Critic architecture&lt;/strong&gt; (1983) and Sutton’s 1984 dissertation, which provided the first rigorous computational analysis of &lt;strong&gt;temporal credit assignment&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 8: The Q-Learning Breakthrough (1988–1994)
&lt;/h3&gt;

&lt;p&gt;This entry documents two watershed moments: &lt;strong&gt;Sutton’s&lt;/strong&gt; 1988 formalisation of TD learning and &lt;strong&gt;Chris Watkins’s&lt;/strong&gt; 1989 introduction of &lt;strong&gt;Q-Learning&lt;/strong&gt;, the first model-free, off-policy algorithm. It also covers the introduction of &lt;strong&gt;SARSA&lt;/strong&gt; (1994) as an on-policy alternative that prioritises training stability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 9: Superhuman Achievement in Games (1992–1999)
&lt;/h3&gt;

&lt;p&gt;This post details &lt;strong&gt;Gerald Tesauro’s TD-Gammon&lt;/strong&gt; (1992), which achieved grandmaster-level backgammon play using neural networks and self-play. It also covers the &lt;strong&gt;options framework&lt;/strong&gt; (1999) by Sutton, Precup, and Singh, which introduced temporal abstraction to help RL agents solve problems across different timescales.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 10: Theoretical Refinement (2000–2010)
&lt;/h3&gt;

&lt;p&gt;This entry explains the &lt;strong&gt;Policy Gradient Theorem&lt;/strong&gt; (2000), which proved that policy parameters could be optimised using only local information. It also introduces Sham Kakade’s &lt;strong&gt;Natural Policy Gradient&lt;/strong&gt; (2002), a precursor to modern trust-region methods that account for the geometry of parameter space.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 11: The Deep RL Revolution (2013–2015)
&lt;/h3&gt;

&lt;p&gt;This post chronicles the birth of &lt;strong&gt;Deep RL&lt;/strong&gt; with DeepMind’s &lt;strong&gt;DQN&lt;/strong&gt; (2013/2015), which used &lt;strong&gt;Experience Replay&lt;/strong&gt; and &lt;strong&gt;Target Networks&lt;/strong&gt; to master Atari games directly from pixels. It also details &lt;strong&gt;DDPG&lt;/strong&gt; (2015), which extended these successes to continuous action spaces like robotics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 12: Mastering Strategy and Control (2015–2017)
&lt;/h3&gt;

&lt;p&gt;This entry explores &lt;strong&gt;Trust Region Policy Optimization (TRPO)&lt;/strong&gt; (2015) and its simpler successor, &lt;strong&gt;Proximal Policy Optimization (PPO)&lt;/strong&gt; (2017), which became the industry standard for stable training. It also covers the historic victory of &lt;strong&gt;AlphaGo&lt;/strong&gt; over Lee Sedol in 2016.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 13: Integrated Mastery: Rainbow and MuZero (2017–2019)
&lt;/h3&gt;

&lt;p&gt;This post details the &lt;strong&gt;Rainbow&lt;/strong&gt; agent (2017), which combined seven independent DQN improvements into one "super-agent". It also highlights &lt;strong&gt;MuZero&lt;/strong&gt; (2019), which learned to master games like Go and Chess without even being told the rules of the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 14: Hard Exploration and Generalisation (2020–2022)
&lt;/h3&gt;

&lt;p&gt;This blog focuses on &lt;strong&gt;Agent57&lt;/strong&gt; (2020), the first agent to surpass the human benchmark on all 57 Atari games by solving "hard exploration" problems. It also covers &lt;strong&gt;Gato&lt;/strong&gt; (2022), a single transformer-based generalist agent capable of playing Atari, captioning images, and controlling robot arms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 15: The Transformer Pivot and LLM Alignment (2021–2023)
&lt;/h3&gt;

&lt;p&gt;This entry describes the &lt;strong&gt;Decision Transformer&lt;/strong&gt; (2021), which reframed RL as a sequence modeling problem, bypassing traditional bootstrapping. It also covers the rise of &lt;strong&gt;Reinforcement Learning from Human Feedback (RLHF)&lt;/strong&gt; with &lt;strong&gt;InstructGPT&lt;/strong&gt; and the subsequent development of &lt;strong&gt;Direct Preference Optimization (DPO)&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 16: Reasoning Models and Incentivized Thought (2024–2025)
&lt;/h3&gt;

&lt;p&gt;This blog explores &lt;strong&gt;DeepSeek Math&lt;/strong&gt; and &lt;strong&gt;GRPO&lt;/strong&gt; (2024), which removed the need for a separate critic model to improve mathematical reasoning. It details the breakthrough of &lt;strong&gt;DeepSeek-R1&lt;/strong&gt; (2024/2025), which proved that pure RL can spontaneously elicit self-correction and reflection in language models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blog 17: Massive Depth and the Future of Scaling (2025–2026)
&lt;/h3&gt;

&lt;p&gt;This final entry discusses the 2025 NeurIPS Best Paper on &lt;strong&gt;1,000-layer RL networks&lt;/strong&gt;, which broke the "shallow network" assumption to unlock 50x performance gains. It reflects on &lt;strong&gt;Kimi k1.5&lt;/strong&gt; and the role of the &lt;strong&gt;2024 Turing Award&lt;/strong&gt; in cementing RL as a foundational pillar of the AI revolution.&lt;/p&gt;

</description>
      <category>rl</category>
    </item>
    <item>
      <title>Personal Health Agent (PHA): Multi-Agent Health System</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:33:43 +0000</pubDate>
      <link>https://dev.to/mitanshgor/personal-health-agent-pha-multi-agent-health-system-1i6l</link>
      <guid>https://dev.to/mitanshgor/personal-health-agent-pha-multi-agent-health-system-1i6l</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=cHYuEzxDJb4" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the last few years, we saw different types of AI systems try to answer this question:&lt;br&gt;
PH-LLM (2024) → focused on personalized coaching from wearable data.&lt;br&gt;
PHIA (2024) → acted like an agent that analyzes your data, writes code, and explains results.&lt;br&gt;
IR Prediction + IR Explainer Agent (2025) → estimated your metabolic risk and explained it like a doctor.&lt;/p&gt;

&lt;p&gt;All of these systems were important steps. But each one had a weakness:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A single LLM tries to do everything.&lt;/li&gt;
&lt;li&gt;It must read data, interpret medical meaning, check safety, and give advice.&lt;/li&gt;
&lt;li&gt;This often leads to confident hallucinations — answers that sound correct but are actually wrong.&lt;/li&gt;
&lt;li&gt;It also mixes medical reasoning with casual coaching, which creates risk. And one model cannot be an expert in every health domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9314ab1b0c2ovlg8crme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9314ab1b0c2ovlg8crme.png" alt="banner" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the big idea behind the Personal Health Agent (PHA) is simple:&lt;/p&gt;

&lt;p&gt;Instead of one giant model doing everything, why not create multiple smaller agents — each with a role — working together like a mini health team?&lt;br&gt;
This solves the main problem with earlier systems: no single AI can fully handle the complexity of real human health. But a team of specialized agents can.&lt;/p&gt;

&lt;p&gt;Because health is multi-dimensional—where your sleep affects your stress, stress affects metabolic health, exercise influences sleep, and food and biomarkers impact everything—one AI model can’t realistically handle all of it at once. Just like a hospital relies on different specialists, a digital health system also needs different “roles”: one agent to interpret raw data, one agent to check medical safety, and one agent to translate insights into simple coaching. This is why multi-agent systems are becoming so important: they add structure, accountability, and more reliable reasoning, solving many of the issues earlier single-LLM systems struggled with.&lt;/p&gt;

&lt;h2&gt;
  
  
  A System of Specialized Agents
&lt;/h2&gt;

&lt;p&gt;When I look at the PHA system, what stands out first is the Analyst Agent. I think of this agent like a friend who loves numbers and graphs. Its whole job is to read my raw data — sleep hours, steps, heart rate, and other signals — and turn them into clear observations. It doesn’t try to coach me or act like a doctor. It just says, “Here’s what I see happening in your data,” which makes everything feel clean and easy to understand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy58om1b0a4jbjs6ocgvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy58om1b0a4jbjs6ocgvd.png" alt="dsAgent" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then there is the Domain Expert Agent, which to me is the “doctor brain” of the whole system. This agent takes what the Analyst found and checks if it makes medical sense. It worries about safety, accuracy, and whether the explanation aligns with real health science. I really like this part because it stops the system from giving random or misleading advice. It acts like the strict friend who always says, “Wait, is this actually correct?”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4rkm5lh1in07tfqpz67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4rkm5lh1in07tfqpz67.png" alt="domainExp" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next comes the Coach Agent, the most human-feeling part of PHA. This agent talks to me like a supportive friend who wants me to succeed. It takes all the technical pieces and translates them into simple, everyday advice I can act on. No medical jargon. No complicated charts. Just small, doable suggestions like, “Try walking after dinner” or “Aim for an earlier bedtime tonight.” It’s friendly and practical, which is exactly what people need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg315ncyax16diti30hvt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg315ncyax16diti30hvt.png" alt="healthcoach" width="799" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What ties everything together is how these agents work as a team. Instead of one giant AI trying to do everything — and often making confident mistakes — each agent stays in its own lane. One analyzes, one verifies, one coaches. Because of this teamwork, the final answer feels clearer, safer, and much more trustworthy. It’s almost like having a mini health team inside your phone, and that makes the whole system feel both smart and human at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Deep Dive
&lt;/h2&gt;

&lt;p&gt;Even though all agents may start from the same base LLM (like Gemini or GPT-class models), they are trained separately, so each one becomes good at one thing instead of being average at everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finetuning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Analyst Agent is finetuned from wearable logs (heart rate, steps, sleep), time-series patterns, data summaries, and statistical examples. It becomes good at reading numbers and spotting patterns.&lt;/li&gt;
&lt;li&gt;Domain Expert needs more serious data for finetuning, like medical guidelines, curated clinical examples, safe/unsafe reasoning samples, and explanations validated by experts. It learns how to avoid hallucinations and unsafe claims&lt;/li&gt;
&lt;li&gt;Coach Agent is the “human” one. It is finetuned on a friendly conversational dataset, lifestyle advice examples, behavior-change coaching patterns. It learns to talk in a simple, supportive way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxutm9nruja3q39zgfr6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxutm9nruja3q39zgfr6h.png" alt="data set" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This division is what makes the final system feel more stable than earlier systems like PHIA or the IR Agent, where a single LLM had to juggle all roles and often made confident mistakes.&lt;/p&gt;

&lt;p&gt;The process itself was simple but very intentional. Here’s how I imagine it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We first collected examples for each agent’s role.&lt;/li&gt;
&lt;li&gt;Then we cleaned and organized everything.&lt;/li&gt;
&lt;li&gt;Then we cleaned and organized everything.&lt;/li&gt;
&lt;li&gt;After that, we fine-tuned each agent separately.&lt;/li&gt;
&lt;li&gt;Then we tested the agents together.&lt;/li&gt;
&lt;li&gt;Finally, we fixed mistakes and improved the dataset.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  System architecture and Data Flow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpizblec7crocjocrwah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpizblec7crocjocrwah.png" alt="system arch" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Underneath all of this, there’s a system architecture that makes their collaboration possible. I picture it like a small command center. The user’s data flows into a main controller, which decides which agent speaks first and who validates whom. The Analyst generates its interpretation, the Domain Expert checks it, and the Coach turns everything into a simple message. Each agent is isolated enough to stay focused, but interconnected enough to build on each other’s work. There’s also a safety layer running quietly in the background — something like a “medical guardrail” — to make sure the final output stays safe, consistent, and responsible before it reaches the user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Pipeline Flow
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;My raw data comes in (wearable data, blood test results, communication history)&lt;/li&gt;
&lt;li&gt;The system cleans and prepares the data.&lt;/li&gt;
&lt;li&gt;The Analyst Agent gets the cleaned data first, and it gives a report.&lt;/li&gt;
&lt;li&gt;The Expert Agent double-checks everything and makes sure the explanation is medically correct and safe.&lt;/li&gt;
&lt;li&gt;The Coach Agent gets the approved explanation and rewrites the message in simple, friendly language&lt;/li&gt;
&lt;li&gt;A final safety filter reviews the message and checks for risky things like any medical diagnosis, unsafe suggestions, and harmful claims.&lt;/li&gt;
&lt;li&gt;I receive the final output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspd5g9lkz788hjcvok15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspd5g9lkz788hjcvok15.png" alt="pipeline inference" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Inference time
&lt;/h3&gt;

&lt;p&gt;During inference — which is just a fancy word for “when the system actually responds to me” — the agents talk to each other almost like coworkers passing notes in a group chat. I don’t see any of this, but it’s happening behind the scenes. The Analyst looks at my raw data and says, “Here’s what I think is happening.” The Domain Expert looks at what the Analyst wrote and either approves it or corrects it. And finally, the Coach turns their combined reasoning into something that sounds human and helpful. What I receive as a single answer is actually the teamwork of multiple roles stitched together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools used
&lt;/h3&gt;

&lt;p&gt;To make all of this work, the system relies on a set of tools that help each agent extend its abilities. The Analyst might use data-processing tools to clean and summarize wearable data. The Domain Expert might have access to reference tools that help it compare findings against medical knowledge or validated guidelines. The Coach might use prompt templates designed for empathy, clarity, and motivation. And the main controller uses orchestration tools — something like LangGraph or a custom workflow engine — to decide who talks when and how information flows between them. These tools don’t replace the agents, but they give them structure, context, and external capabilities they wouldn’t have on their own.&lt;/p&gt;

&lt;h3&gt;
  
  
  Collection of data
&lt;/h3&gt;

&lt;p&gt;Everything starts with a real study they ran called &lt;strong&gt;WEAR-ME&lt;/strong&gt;, which included more than a thousand Fitbit users. People had to explicitly opt-in, sign digital consent, link their wearable device, and even go for a blood draw at a Quest Diagnostics center. So the data wasn’t scraped or assumed—it came from real people who agreed to share it for research. That part mattered to me because it made the whole system feel responsible, not rushed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozrz0zw4prfut4yef2yk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozrz0zw4prfut4yef2yk.png" alt="data1" width="799" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once someone joined the study, their data flowed through a very controlled pipeline.So each person had a mix of: (1) wearable time-series, (2) lab biomarkers, (3) self-reported history, (4) lifestyle questionnaires.&lt;/p&gt;

&lt;p&gt;What I liked is that the system doesn’t directly reach into a live Fitbit account or do anything “real-time.” Instead, the PHA gets access to summaries of the participant’s data, organized into tables—like a daily summary table, an activities table, and even a population-level reference table so the system could compare one user’s values against others in their age group. This gave context, not just raw numbers.&lt;/p&gt;

&lt;p&gt;Inside the actual agent pipeline, each sub-agent only receives the part of the data that’s relevant to its job. The system never dumps the full raw dataset into every agent. Instead, the orchestrator acts like a coordinator who hands the right information to the right specialist. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34ozz316vec63s0dh1mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34ozz316vec63s0dh1mi.png" alt="data2" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing is fetched unless the user asks something that genuinely needs it. And the system also avoids asking the user for things it already knows—like their sleep hours or steps—because the orchestrator checks the available data first.&lt;/p&gt;

&lt;h2&gt;
  
  
  PHA vs Gemini Results
&lt;/h2&gt;

&lt;p&gt;PHA wasn’t just a small improvement. It was in a completely different league.&lt;/p&gt;

&lt;p&gt;From the end-user side, I noticed that people consistently picked PHA as the best experience. Not just once or twice — almost half the time. And this is after comparing it side-by-side against a single Gemini agent and a parallel multi-agent system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsqsilw9r4hl35m3n5xs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsqsilw9r4hl35m3n5xs.png" alt="enduser" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the biggest eye-opener for me was the expert evaluation. Experts didn’t just prefer PHA — they almost abandoned the Gemini single-agent baseline. Only around 4–5% of expert rankings put Gemini in first place, while PHA was chosen as #1 about 80% of the time. That’s not a small margin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yxu0ccew7z9qmoo2mba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yxu0ccew7z9qmoo2mba.png" alt="expUser" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Strengths of the system
&lt;/h2&gt;

&lt;p&gt;What struck me most was how real the system felt. Not just in terms of architecture, but in how thoroughly it was tested. It wasn’t a small demo — it involved thousands of human annotations and hundreds of hours of expert evaluation. Because of that, the strengths and limitations felt very honest.&lt;/p&gt;

&lt;p&gt;One of the biggest strengths I noticed is how well the whole system comes together. The three-agent setup — the data scientist, the domain expert, and the coach — isn’t just theoretical. In the evaluations, PHA actually outperformed both a single-agent system and a parallel multi-agent system. End-users preferred talking to PHA almost half the time, and experts loved it even more, choosing it as the best system in about 80% of cases. To me, that says the collaboration between these agents isn’t just helpful — it genuinely changes the quality of the conversation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbzp9nzsn8e7xq9ytewz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbzp9nzsn8e7xq9ytewz.png" alt="daAdv" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data agent in particular felt like a major upgrade. It was much better at breaking down messy, vague health questions into proper statistical analyses, catching missing data, choosing the right timeframes, and generating correct code. I could see why the system became more trustworthy — it wasn’t guessing. It was reasoning over the user’s actual data. And the domain expert agent made a big difference too. It produced safer, more accurate, and more personalized medical explanations. Users rated its responses as far more trustworthy than the base model, and clinicians preferred its summaries because they were more complete and clinically meaningful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr1mvix1o1lhgkrxff2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr1mvix1o1lhgkrxff2f.png" alt="domainAdv" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The health coach agent also impressed me. It wasn’t just delivering motivational lines. It followed real coaching principles — active listening, SMART goals, motivational interviewing — and this made conversations feel more natural and supportive. Users were more engaged, and the conversations ended more naturally. It reminded me of talking to a real human coach who’s actually paying attention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpetug6re3d588sbi666a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpetug6re3d588sbi666a.png" alt="coachAdv" width="800" height="723"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a whole system, PHA feels more thoughtful. The orchestrator doesn’t just mix answers together — it understands the user’s goal, assigns the right agent, reflects on the output, and remembers important details for later turns. This gives the conversation a sense of direction and personalization that the baselines just didn’t have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations of the System
&lt;/h2&gt;

&lt;p&gt;But the system isn’t perfect. One thing that stood out immediately was the cost. PHA is slower and more computationally expensive because each request triggers multiple agents and reflection steps. Where the single-agent system might respond in around 35 seconds, PHA could take over 200. It’s powerful, but not cheap.&lt;/p&gt;

&lt;p&gt;Another limitation is that the diagnostic reasoning, while improved, is still not bulletproof. Sometimes the domain expert agent didn’t complete its reasoning chain, and its reliance on web search occasionally pulled in conflicting information. This reminded me that, even though it acts like a doctor in some ways, it’s not actually one — and the authors make that very clear.&lt;/p&gt;

&lt;p&gt;Bias is also a real concern. The system personalizes advice based on user traits, conditions, and context… which is great, but it also means it can unintentionally repeat patterns or assumptions from datasets that might not represent everyone equally. The paper calls out this risk directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq9spxcb92u8fqw3qlnw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq9spxcb92u8fqw3qlnw.png" alt="Limitations" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The coach agent, despite being strong overall, also had a weakness: it wasn’t great at tracking user progress over time. It did a good job helping set goals, but didn’t always follow up on them in later turns. For long-term coaching, that’s something they’ll need to improve.&lt;/p&gt;

&lt;p&gt;And finally — maybe the biggest limitation — everything was tested in short-term interactions. We don’t yet know whether PHA can support behavior change over weeks or months, which is where health coaching really matters. The team also notes that this is a research framework, not a clinical tool, and major regulatory work would be needed before deploying anything like this in the real world.&lt;/p&gt;

&lt;p&gt;So when I put it all together, here’s how I personally see it:&lt;br&gt;
PHA is a huge improvement over past systems — smarter, safer, more human, and more useful — but it’s still early. It has real strengths, but also real gaps. It’s powerful as an idea, promising as a system, and clearly built with care. But it also reminds me that great AI doesn’t replace medical care — it supports it, and it still has a lot of growing up to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;After reading the PHA paper, the biggest thing I realized is that this system isn’t just an AI answering health questions — it feels more like a small team working behind the scenes to help you make sense of your own data. The evaluations show that this multi-agent design really does lead to better, clearer, and more personalized guidance compared to older single-agent approaches.&lt;/p&gt;

&lt;p&gt;At the same time, the authors are very honest about their limits. The system can still make mistakes, it can be biased depending on the data, and it should never replace real medical care. It’s powerful, but it’s also early — more like a research blueprint than a ready product.&lt;/p&gt;

&lt;p&gt;To me, PHA represents a hopeful direction: AI that supports people in understanding their health, not by taking over, but by helping them make smarter choices with empathy, safety, and transparency in mind&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>health</category>
      <category>google</category>
    </item>
    <item>
      <title>PHIA: The Agentic LLM That Writes Code, Analyzes Your Data &amp; Explains Health Insights</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:33:34 +0000</pubDate>
      <link>https://dev.to/mitanshgor/phia-the-agentic-llm-that-writes-code-analyzes-your-data-explains-health-insights-4g1a</link>
      <guid>https://dev.to/mitanshgor/phia-the-agentic-llm-that-writes-code-analyzes-your-data-explains-health-insights-4g1a</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=UR2MTLJ1d4E" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I honestly felt like I was looking at the “next version” of what health AI should be. Whenever I asked myself questions like, “Is my sleep improving?” or “Does exercising at night change my deep sleep?”, I realized how hard it is to answer these without real analysis.&lt;/p&gt;

&lt;p&gt;That is exactly the problem the PHIA team talks about on page 1 of the paper. They explain that even a simple question like “Do I sleep better after exercising?” requires many steps: checking recent data, comparing different days, calculating metrics, and then interpreting everything in the context of what “healthy” even means. And honestly, I could relate — that’s the kind of analysis I never do on my own.&lt;br&gt;
What really caught my attention is that the paper says today’s LLMs struggle with numerical reasoning, meaning they often miscalculate or oversimplify things. I’ve definitely seen models do that — giving a confident answer but completely messing up basic math. (Limitation of PH-LLM)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijr3r0wiwgfamfnpd0dv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijr3r0wiwgfamfnpd0dv.png" alt="int" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So PHIA tries to fix this problem by giving an LLM the ability to plan, use tools, write code, and search the web. It doesn’t just “chat.” It becomes more like a small data analyst that works with your wearable data step-by-step.&lt;/p&gt;

&lt;h2&gt;
  
  
  PH-LLM vs PHIA
&lt;/h2&gt;

&lt;p&gt;PH-LLM was an earlier coaching system that worked only with simple, pre-aggregated 30-day summaries and relied purely on the LLM’s internal reasoning. That meant it couldn’t actually analyze detailed daily wearable data, couldn’t run calculations, and completely failed on questions that required numbers or step-by-step reasoning. PHIA addresses these limitations by granting the LLM three new capabilities: (1) it can generate authentic Python code to analyze raw wearable data, (2) it can plan and break down tasks using an agent loop, and it can search the web to incorporate fresh, verified health knowledge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8xekitn7246fd5p1e9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8xekitn7246fd5p1e9k.png" alt="difference" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because of this, PHIA shifts from being “just a health coach” to becoming a true data analyst + coach, delivering insights that are more accurate, personalized, and grounded in both the user’s data and real health science. PHIA feels like the bridge between “AI as a friendly coach” and “AI as a personal data scientist.” By mixing reasoning, code execution, and web search, it finally unlocks the kind of deeper, more accurate insights that wearables have always had the potential to provide.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqkihmir6plcn25xlyp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqkihmir6plcn25xlyp4.png" alt="diff" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How PHIA Works
&lt;/h2&gt;

&lt;p&gt;PHIA more like a mini health data analyst that can think step-by-step, write code, check your wearable data, search the web, and then explain everything in normal language. The PHIA paper shows this clearly — PHIA literally cycles through think → act → observe just like a human analyst would.&lt;/p&gt;

&lt;p&gt;I’ll explain this in the simple way I understood it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9fqs7m9hl4jtzdwrc61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9fqs7m9hl4jtzdwrc61.png" alt="ReAct" width="799" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of guessing answers, PHIA acts more like a small data analyst that plans its steps, checks your wearable data, and only then explains what it found. The paper describes this using the ReAct loop— &lt;strong&gt;Thought → Action → Observation&lt;/strong&gt; — and seeing it in action helped me understand why PHIA is so different.&lt;/p&gt;

&lt;p&gt;PHIA starts by thinking through the question. If I ask something like “Is my resting heart rate improving?”, it doesn’t jump to a quick reply. It pauses and decides what it needs—maybe comparing two weeks of data or calculating averages. Then, PHIA takes action by writing and running Python code in a safe &lt;strong&gt;virtual environment tool&lt;/strong&gt;. This lets it analyze real daily time-series data using Pandas, just like a real data scientist. The nice part is that this removes mathematical mistakes that normal LLMs often make. And if its code crashes, PHIA actually fixes the error and tries again (&lt;u&gt;recurrent trials system&lt;/u&gt;), which the paper highlights as one of its strengths.&lt;/p&gt;

&lt;p&gt;In their evaluation, PHIA scored &lt;strong&gt;84% accuracy&lt;/strong&gt; on objective questions, way higher than simple LLM reasoning. This happens because PHIA can recover when the code fails.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p6ma2p9tzg1o75gjizq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p6ma2p9tzg1o75gjizq.png" alt="ReAct Arch" width="799" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a question requires more than numbers—like understanding recommended sleep hours—PHIA uses a built-in web &lt;strong&gt;search tool&lt;/strong&gt; to fetch verified information from trusted sources.  Sometimes the user needs context, like: “Is this amount of sleep normal for my age?” “What workouts improve resting heart rate?” “Is my stress score healthy?”&lt;br&gt;
PHIA has a built-in search tool that pulls information from verified online sources. This mixing of data + domain knowledge is what makes PHIA feel smart and practical.&lt;/p&gt;

&lt;p&gt;What impressed me most is how PHIA blends everything together. It doesn’t just give numbers or copy facts. It calculates, it checks, it researches, and then it explains the result in clear language. The examples in the paper, like &lt;u&gt;comparing a user’s sleep with national guidelines&lt;/u&gt;, really show how these steps come together. In the end, PHIA feels less like a chatbot and more like someone doing careful, step-by-step reasoning to help you understand your own health patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Deep Dive Into PHIA’s Technical Architecture
&lt;/h2&gt;

&lt;p&gt;PHIA is not a fine-tuned model. It’s an agent framework built around &lt;strong&gt;&lt;u&gt;Gemini 1.0 Ultra&lt;/u&gt;&lt;/strong&gt;, with two major tools: (1) Python data analysis runtime, (2) Web search tool.&lt;/p&gt;

&lt;p&gt;These tools are orchestrated using the ReAct (Reason + Act) agent pattern, which is why PHIA can do multi-step reasoning without fine-tuning. This design gives PHIA abilities that raw LLMs don’t have: planning, correction, stepwise attention, and grounded analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  No Fintuning
&lt;/h3&gt;

&lt;p&gt;One of the most interesting things I learned from the paper is that PHIA is not fine-tuned like PH-LLM. Instead of modifying the model’s weights, the authors built a smart scaffolding around the model and taught it how to act like an agent.&lt;/p&gt;

&lt;p&gt;Fine-tuning a huge LLM like Gemini Ultra is expensive, slow, requires tons of supervised data, and risky (can break general reasoning ability).&lt;/p&gt;

&lt;p&gt;So instead, PHIA keeps the base model untouched and teaches the model how it should “think” and use tools using few-shot ReAct examples.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a totally different philosophy: PH-LLM → change the model. PHIA → change the system around the model&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Process
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The authors started with thousands of wearable-related questions (objective + open-ended). They needed a tiny set of example tasks that could teach the model how to behave like an agent.&lt;/li&gt;
&lt;li&gt;Instead of randomly picking examples, they converted every question into numerical embeddings using Sentence-T5. This turns each question into a vector representing its meaning, so similar questions sit close together in vector space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpyn3yfndl2r7mcb4vox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpyn3yfndl2r7mcb4vox.png" alt="Process" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They ran k-means clustering (k=20) on these embeddings to automatically group similar questions into 20 clusters. Each cluster represents a whole “type” of question, like sleep trends, workout comparisons, anomaly detection, correlations, and so on.&lt;/li&gt;
&lt;li&gt;From each cluster, they selected the most central question — the one closest to the cluster centroid.This gives 20 representative queries, each standing in for a larger family of similar queries.&lt;/li&gt;
&lt;li&gt;For each of these 20 representative queries, the team manually wrote a complete ReAct agent trajectory that included every step of reasoning:

&lt;ul&gt;
&lt;li&gt;Thought: what the model should plan to do&lt;/li&gt;
&lt;li&gt;Action (Python): the exact Pandas code needed&lt;/li&gt;
&lt;li&gt;Observation: the real output that the code would return&lt;/li&gt;
&lt;li&gt;Thought again: interpreting the output&lt;/li&gt;
&lt;li&gt;Action (Search): when domain knowledge is needed&lt;/li&gt;
&lt;li&gt;Observation: the retrieved information&lt;/li&gt;
&lt;li&gt;Final Answer: a clear, natural-language explanation. These aren’t partial examples — they are full step-by-step walkthroughs that demonstrate how an agent should behave.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;These 20 full trajectories were inserted into PHIA’s few-shot prompt, acting as demonstrations inside its system instructions. So the model is not fine-tuned — instead, it is taught by example how to: plan before acting, decide when to run code, decide when to search the web, fix code errors, combine numerical results with domain knowledge, and produce a final personalized insight.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This is called “behavior cloning via prompting.” : It will learn the “pattern of behavior” from the examples, even without changing its internal parameters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;PHIA is a perfect example of how powerful LLMs become when they are paired with the right scaffolding instead of relying only on internal reasoning. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezd2e5c7ozuk7p1ljgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezd2e5c7ozuk7p1ljgh.png" alt="graph" width="800" height="697"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations in the PHIA
&lt;/h2&gt;

&lt;p&gt;PHIA is a huge step forward, especially compared to simple chat-based coaching. But it’s still early-stage. It shows what’s possible when LLMs use tools, but it also exposes how much work is left to make an AI truly trustworthy in personal health.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHIA hasn’t been tested on real people yet, so we still don’t know if it truly helps users change habits or understand their health better in everyday life.&lt;/li&gt;
&lt;li&gt;It only uses wearable data, and I feel it needs more context—like nutrition, medical records, or mood logs—to give deeper and more holistic insights.&lt;/li&gt;
&lt;li&gt;PHIA isn’t medically validated, so even though it sounds smart, its recommendations haven’t been checked by doctors or health experts for real accuracy. Personalization still feels limited, because sometimes PHIA gives generic advice even when the user’s data is available right there.&lt;/li&gt;
&lt;li&gt;Its reasoning depends heavily on prompting and Gemini Ultra, which means its behavior might change across models or updates, making it less consistent.&lt;/li&gt;
&lt;li&gt;Error handling is better than basic LLMs but still imperfect, since PHIA can misread data columns or fail on messy real-world data.&lt;/li&gt;
&lt;li&gt;Its toolset is still narrow, and I’d love to see it generate visualizations, analyze other health signals, or track long-term goals instead of just answering one question at a time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learnings from the paper
&lt;/h2&gt;

&lt;p&gt;Reading the PHIA paper honestly changed the way I think about building AI systems. Before this, I used to focus mainly on making the model smarter, but PHIA showed me that the real progress comes from giving the model the right tools and the right structure. Seeing how PHIA uses the ReAct loop—think, act, observe—made me realize how important disciplined reasoning is for avoiding hallucinations and building trust.&lt;/p&gt;

&lt;p&gt;The use of synthetic data was another eye-opener, because it proved that we can train and evaluate personal-health agents responsibly without touching real user data. On top of that, the way the authors handled safety—650 hours of human review, strict guardrails, and cautious refusal behavior—reminded me that responsible AI isn’t optional; it’s part of the engineering.&lt;/p&gt;

&lt;p&gt;More than anything, PHIA taught me that the future of AI isn’t “a bigger model,” but a system where models, tools, data, and reasoning frameworks all work together. As an AI engineer, this shifted how I think about agents: not as chatbots, but as full pipelines designed to solve real problems with accuracy, humility, and safety.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Insights I’m Taking With Me
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PHIA wins because it’s structured, not because the LLM is smarter.&lt;/li&gt;
&lt;li&gt;Reasoning and architecture beat raw model size.&lt;/li&gt;
&lt;li&gt;PHIA shines when a question needs data + external knowledge + multi-step logic, not just basic statistics.&lt;/li&gt;
&lt;li&gt;Its real strength is disciplined reasoning, not raw computation.&lt;/li&gt;
&lt;li&gt;PHIA’s strict safety guardrails make it trustworthy in a way normal LLMs aren’t.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>google</category>
      <category>health</category>
    </item>
    <item>
      <title>PH-LLM - A LLM that gives personalized sleep and fitness coaching using wearable data.</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:32:57 +0000</pubDate>
      <link>https://dev.to/mitanshgor/ph-llm-a-llm-that-gives-personalized-sleep-and-fitness-coaching-using-wearable-data-2m7f</link>
      <guid>https://dev.to/mitanshgor/ph-llm-a-llm-that-gives-personalized-sleep-and-fitness-coaching-using-wearable-data-2m7f</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=G-n7BMqxJqk" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PH-LLM (Personal Health Large Language Model) is a version of Gemini Ultra that has been fine-tuned specifically for sleep and fitness coaching. It isn’t just chatting—it actually learns from up to 30 days of wearable data, understands your patterns, and gives expert-level insights. The research paper shows PH-LLM scoring 79% on sleep medicine exams and 88% on fitness exams, which is on par or better than the expert groups they tested with.&lt;/p&gt;

&lt;p&gt;What really caught my interest is that the system can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;analyze daily-resolution sensor data&lt;/li&gt;
&lt;li&gt;generate personalized insights&lt;/li&gt;
&lt;li&gt;Predict how rested or tired you will feel based only on wearable data and speak to you like a sleep coach or fitness expert.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5efo1s358xmkr5lfp16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5efo1s358xmkr5lfp16.png" alt="system can solve 3 tasks" width="799" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Problem PH-LLM Tries to Solve
&lt;/h2&gt;

&lt;p&gt;Wearables track you, but they don’t talk to you. They tell you what happened, but not why it happened or how to fix it. PH-LLM aims to act like a personal health coach — one that understands your data, your patterns, your goals, and the science behind all of it.&lt;/p&gt;

&lt;p&gt;Instead of treating sensor data like random numbers on a dashboard, it tries to interpret them the way a human expert would. If your bedtime has been drifting later over the past two weeks, or your deep sleep dropped right after you increased workout intensity, PH-LLM doesn’t just point it out — it explains why it happened and how it connects to your goals. It transforms passive metrics into an actual conversation about your habits.&lt;/p&gt;

&lt;p&gt;The system was trained specifically for this kind of reasoning. The researchers fine-tuned Gemini Ultra so it could combine textbook knowledge with real-world wearable data. Interestingly, PH-LLM doesn’t just “sound smart.” In testing, it actually outperformed sleep experts on sleep medicine exam questions and matched them in fitness knowledge. That means the model isn’t just giving generic advice — it has a near-expert understanding of the underlying science.&lt;/p&gt;

&lt;p&gt;But what really makes PH-LLM different is that it doesn’t stop at general knowledge. It looks at a person’s actual patterns over weeks. If you always sleep well on weekdays but crash on weekends, it's noticeable. If your HRV is dropping while your workouts are getting harder, it connects the dots. In one of the paper’s examples, the model realized a user had a very regular sleep schedule but consistently slept too little, and it suggested shifting bedtime by small increments rather than giving a one-size-fits-all rule. That’s the kind of nuance real coaches provide, but most apps don’t.&lt;/p&gt;

&lt;h2&gt;
  
  
  High-level Working of the PH-LLM
&lt;/h2&gt;

&lt;p&gt;Researchers took Gemini Ultra — a very capable general-purpose model — and taught it how to understand sleep and fitness the same way a human expert would. They basically turned a large language model into a personal health specialist.&lt;/p&gt;

&lt;p&gt;The process happened in two major steps. First, they fine-tuned the entire Gemini Ultra model on hundreds of detailed sleep and fitness case studies. These weren’t made-up examples — each case study was based on real wearable data from real people. The case studies included up to thirty days of information such as bedtimes, wake times, restlessness, workout intensity, heart rate metrics, and more. Alongside the data, sleep physicians and athletic trainers wrote expert-level insights, possible causes, and recommendations. These human-written explanations became the “teacher examples” that the model learned from. By imitating these expert responses over and over, PH-LLM learned how to talk like a coach and reason like one too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy98wa021cc4x12jo4c5a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy98wa021cc4x12jo4c5a.png" alt="case study" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, the researchers added a second layer of training using something called a multimodal adapter. This part fascinated me because it let the model go beyond simple text input. Instead of only reading written summaries of the user’s data, PH-LLM also receives a compressed representation of the actual sensor values — the statistical patterns hidden in daily heart rate, HRV, sleep duration, respiratory rate, and other signals across fifteen days. These adapter-generated “soft tokens” get injected directly into the LLM’s internal understanding. In simple terms, the model doesn’t just read your data — it absorbs it. This is how PH-LLM can predict things like “Will this person feel tired tomorrow?” with accuracy on par with traditional machine learning approaches.&lt;/p&gt;

&lt;p&gt;The result of these two training phases is a model that can look at your daily metrics and instantly form a holistic picture. If your bedtime keeps drifting later, PH-LLM notices. If your deep sleep drops right after your workout intensity spikes, it picks up the relationship. If your HRV has been declining all week, it connects that to stress, recovery, or the need for rest. What impressed me is that PH-LLM isn’t just matching patterns — it can articulate the reasoning behind them, almost like an expert thinking out loud.&lt;/p&gt;

&lt;p&gt;The paper shows a great example of this. For one user, the model pointed out that the midsleep point was extremely consistent — meaning their circadian rhythm was stable — but their total sleep time was consistently too low. From there, PH-LLM suggested a gradual shift in bedtime over several days. This wasn’t a generic “try to sleep more” tip; it was a specific plan tailored to what the data actually showed. That kind of reasoning is the whole point of the system.&lt;/p&gt;

&lt;p&gt;Another thing I appreciated is that PH-LLM adapts its responses based on how much data it has. When the researchers removed parts of the input — like today’s sleep metrics or the last week of workout logs — PH-LLM still adjusted its explanations in a sensible way. To me, this shows that the model doesn’t rely on memorized patterns but actually understands the structure of sleep and fitness behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Working
&lt;/h2&gt;

&lt;p&gt;The foundation of PH-LLM is Gemini Ultra 1.0, Google’s flagship multimodal model. In this work, it functions mainly as a text LLM (the vision-side is not used). Structurally, it’s a Transformer decoder with extremely large context and token embedding dimensions. This gives it the capacity needed to reason across long-form case studies, sleep explanations, and multi-step fitness logic.&lt;/p&gt;

&lt;p&gt;The base model (Gemini Ultra 1.0) already has strong performance in medical question answering and general health reasoning. But by itself, it doesn’t know how to interpret raw wearable data — it needs domain-specific training.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finetuning
&lt;/h3&gt;

&lt;p&gt;The first major training step is a full-parameter finetuning of Gemini Ultra on 857 expert-annotated sleep and fitness case studies. Each case study includes: (1) Up to 30 days of daily metrics, (2) Aggregated (mean, variance, percentiles) statistics, (3) Expert-written insights, etiologies, and recommendations. This dataset is unique because each example combines real sensor patterns with expert-level reasoning. When the researchers fine-tuned the model, they essentially taught it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“When you see patterns like this in the data, here’s how a real sleep doctor or athletic trainer explains it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r28f6w5d75qwklf8o5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r28f6w5d75qwklf8o5e.png" alt="Fine Tuned" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To teach Gemini Ultra how to behave like a real sleep and fitness coach, the researchers fine-tuned the entire model—not just a small part of it—using a large collection of expert-written examples. Each example paired a user’s real wearable data with the exact explanation a sleep doctor or athletic trainer would give. There were about thirteen hundred of these pairs for sleep and fifteen hundred for fitness, and the model was trained on them over roughly fifteen hundred optimization steps. Instead of using shortcuts like LoRA, they updated all of the model’s weights directly, following a smooth cosine schedule for the learning rate so the model gradually stabilized as it learned. After this full training process, the base Gemini model effectively “became” PH-LLM: an LLM that now understands how to read multi-day sensor patterns and talk like a personal health expert.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multimodal Adapter for Sensor Data
&lt;/h3&gt;

&lt;p&gt;Once PH-LLM can generate coaching advice, the second challenge is enabling it to interpret raw numerical sensor data for prediction tasks (like estimating how tired someone will feel).&lt;/p&gt;

&lt;p&gt;To do this, the researchers added a custom MLP-based multimodal adapter. This is the most “technical” part of the architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvb7hndcteg79bo0a1qgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvb7hndcteg79bo0a1qgn.png" alt="Multimodal Adapter" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How the adapter works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For each of the 20 wearable sensor signals (HRV, resting HR, sleep duration, etc.), the system collects 15 days of values.&lt;/li&gt;
&lt;li&gt;It computes standardized mean and variance for each signal.&lt;/li&gt;
&lt;li&gt;These 40 numbers (20 means + 20 variances) feed into a multi-layer perceptron (MLP):

&lt;ul&gt;
&lt;li&gt;Input: 40&lt;/li&gt;
&lt;li&gt;Hidden layers: 1024 → 4096 → 1024 (ReLU activations)&lt;/li&gt;
&lt;li&gt;Output: 4 “soft tokens,” each of size 14,336 (the embedding size of PH-LLM).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;These 4 soft tokens are prepended to the text input as if they were real tokens.&lt;/li&gt;
&lt;li&gt;The LLM then processes the numerical data inside its own embedding space, letting its reasoning layers combine subjective sleep patterns with wearable readings&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The LLM never sees raw numbers — it sees learned embeddings representing the person’s physiological state. This allows PH-LLM to achieve machine-learning level accuracy in predicting subjective sleep outcomes, without needing a separate ML pipeline.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Input Format and Context Handling
&lt;/h3&gt;

&lt;p&gt;The system uses two kinds of input representations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Textual Representations

&lt;ul&gt;
&lt;li&gt;Daily tables written out in text&lt;/li&gt;
&lt;li&gt;Time ranges (bedtime, sleep duration)&lt;/li&gt;
&lt;li&gt;Percentile comparisons&lt;/li&gt;
&lt;li&gt;Metric summaries&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Soft Token Representation via Adapter

&lt;ul&gt;
&lt;li&gt;Encodes underlying numerical structure&lt;/li&gt;
&lt;li&gt;Injected directly into the model’s attention layers&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyollwpfqcdqvz3ggyqf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyollwpfqcdqvz3ggyqf.png" alt="input format" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because PH-LLM was trained on long, structured case studies, it naturally handles: multi-day patterns, variations in missing data, differences in available context.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Output Structure
&lt;/h3&gt;

&lt;p&gt;PH-LLM produces multi-part responses in the same structure experts use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Insights: Patterns detected in the data&lt;/li&gt;
&lt;li&gt;Etiology: Possible causes based on sleep medicine frameworks (like RU-SATED)&lt;/li&gt;
&lt;li&gt;Recommendations: Personalized, SMART-style advice&lt;/li&gt;
&lt;li&gt;Readiness Scoring (Fitness): Evaluation of fatigue, HRV trends, and recovery loads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Full7svmjpuvkmtlv0ek4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Full7svmjpuvkmtlv0ek4.png" alt="output structure" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because the model was trained on structured expert templates, it learns to produce cohesive, medically-grounded narratives instead of generic advice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Evaluation Architecture
&lt;/h3&gt;

&lt;p&gt;The team built a secondary system called &lt;strong&gt;AutoEval&lt;/strong&gt;, which is an LLM finetuned to grade PH-LLM’s responses against expert criteria. This created an automated loop for model validation, enabling: fast benchmarking, ablation studies, large-scale quality scoring.&lt;br&gt;
AutoEval itself is built using Gemini Pro with LoRA finetuning&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflzsbauapv7l5oq46m0x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflzsbauapv7l5oq46m0x.png" alt="Evaluation Arch" width="800" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Strengths of the system
&lt;/h2&gt;

&lt;p&gt;What I like most about PH-LLM is how personal it feels. Instead of giving generic sleep or fitness advice, it actually looks at your patterns over weeks and speaks to you the way a real coach would. When it notices your bedtime shifting or your deep sleep dropping after intense workouts, it doesn’t just state the numbers—it explains what those changes mean and why they matter.&lt;/p&gt;

&lt;p&gt;The system’s expert-level reasoning also stands out. In the paper, PH-LLM &lt;strong&gt;performs as well as or better than trained professionals&lt;/strong&gt; on board-style sleep and fitness exams, scoring &lt;u&gt;79% in sleep medicine&lt;/u&gt; and &lt;u&gt;88% in fitness&lt;/u&gt;. This gives its recommendations a level of credibility that most consumer health apps don’t have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1yk9ktks5jjb3gl55nj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1yk9ktks5jjb3gl55nj.png" alt="trained professionals vs PHLLM" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another strength is how smoothly it blends wearable data with human-like reasoning. Using the multimodal adapter, PH-LLM can predict subjective feelings like tiredness or restfulness based purely on sensor trends, something even many traditional ML models struggle with.&lt;/p&gt;

&lt;p&gt;Finally, PH-LLM adapts well when information is missing or incomplete. The paper shows that when certain sleep or workout metrics are removed, the model still adjusts its reasoning instead of failing outright. That flexibility makes it feel more intelligent and reliable, almost like it truly understands how sleep and fitness behaviors change from day to day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;The biggest one, in my opinion, is its dependence on the quality of the wearable data itself. If your device misreads your sleep stages or your heart rate jumps around because the watch wasn’t snug, PH-LLM will still try to interpret that noise as if it’s meaningful. The paper even points out that the model sometimes references data incorrectly or forms conclusions that don’t perfectly match the input — small confabulations that become more noticeable when the data is messy&lt;/p&gt;

&lt;p&gt;Another issue is that the model sometimes struggles with consistency when giving recommendations. For sleep insights, the fine-tuning helped a lot, but for fitness coaching the improvements were smaller, and in certain sections like “training load,” PH-LLM actually performed worse than the base Gemini model and human experts.&lt;strong&gt;&lt;u&gt; That tells me the model doesn’t fully grasp every fitness scenario as deeply as it understands sleep patterns.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The paper itself admits there were demographic skews — more middle-aged users, fewer younger or older participants, and no information about race or ethnicity. That means the &lt;strong&gt;eva&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And finally, there’s the broader limitation that PH-LLM, no matter how smart it sounds, is not a medical device. It can give coaching-style suggestions, but it isn’t validated for clinical decision-making. Sometimes its tone feels authoritative, which can make the advice sound more medically precise than it actually is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Takeaways
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprfuqfo9k4xwc0ftalxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprfuqfo9k4xwc0ftalxb.png" alt="summarize" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What impressed me most is the model’s ability to turn a messy week of habits into a simple, actionable story. It doesn’t lecture or overwhelm. It just explains what’s going on and nudges you in the right direction. At the same time, it’s important to remember that PH-LLM isn’t a medical system. It still makes small mistakes, relies heavily on the data it sees, and carries the biases of the Fitbit-dominated population it was trained on.&lt;/p&gt;

&lt;p&gt;But the core idea feels powerful. PH-LLM represents a shift from “apps that measure you” to “systems that understand you.” This paper is a glimpse of where personal health AI is heading, and it sets a strong foundation for the next models I’ll be reviewing in this series. As I move into PHIA, the IR Explainer Agent, and later multi-agent systems, I can already see how all these ideas start to connect. PH-LLM feels like the first major building block in creating an AI that doesn’t just track your health—but helps you improve it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Data + code: &lt;a href="https://github.com/google-health/consumer-health-research" rel="noopener noreferrer"&gt;https://github.com/google-health/consumer-health-research&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;NSCA: &lt;a href="https://www.nsca.com/certification/cscs/certified-strength-and-conditioning-specialist-exam-description" rel="noopener noreferrer"&gt;https://www.nsca.com/certification/cscs/certified-strength-and-conditioning-specialist-exam-description&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Healthcare Board Exam: &lt;a href="https://www.boardvitals.com/" rel="noopener noreferrer"&gt;https://www.boardvitals.com/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>google</category>
      <category>ai</category>
      <category>health</category>
      <category>llm</category>
    </item>
    <item>
      <title>AI for Personal Health — My Review, Reflections &amp; Real-Life Understanding</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Thu, 27 Nov 2025 05:32:31 +0000</pubDate>
      <link>https://dev.to/mitanshgor/ai-for-personal-health-my-review-reflections-real-life-understanding-12kh</link>
      <guid>https://dev.to/mitanshgor/ai-for-personal-health-my-review-reflections-real-life-understanding-12kh</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=0JXDsAcQ6JU" rel="noopener noreferrer"&gt;VIDEO LINK&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I’ve been using wearables like Fitbit and Pixel Watch for a while, and I’ve always had the same question in the back of my mind:&lt;br&gt;
&lt;strong&gt;“These devices collect so much data… but what does it actually mean for my health?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I could see my steps, sleep score, heart rate, all the usual numbers — but I didn’t really know how to connect them to real insights about my body. That curiosity is what pulled me into this world of AI for personal health.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2fxpfyi8zq3goovtaoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2fxpfyi8zq3goovtaoh.png" alt="i am personal coach" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I started reading research papers and experimenting with data, I realized something important:&lt;br&gt;
&lt;strong&gt;AI is slowly becoming the “missing link” between raw wearable data and actual, useful guidance.&lt;/strong&gt;&lt;br&gt;
It can interpret patterns, explain them in simple language, and sometimes even coach you like a personal guide.&lt;/p&gt;

&lt;p&gt;This blog series is my attempt to share what I learned — not as a researcher writing a formal report, but as a student trying to make sense of a fast-moving field in a friendly, simple way.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What This Series Will Cover (Based on the Timeline of Publications)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I studied four papers and mapped out how AI in personal health evolved over the past few years.&lt;br&gt;
Here’s the order I’ll follow in this series — from earlier work to the most recent:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pkx6pw5z4uwcispwd3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pkx6pw5z4uwcispwd3v.png" alt="timeline" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intro Blog (this one)&lt;/strong&gt; - Why I’m exploring this topic and how the whole series is structured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 1 (2024)&lt;/strong&gt; — &lt;strong&gt;PH-LLM&lt;/strong&gt; - A large language model that gives personalized sleep and fitness coaching using wearable data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 2 (2024)&lt;/strong&gt; — &lt;strong&gt;PHIA&lt;/strong&gt; - An agentic LLM that writes code, analyzes your data, and turns it into meaningful health insights.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 3 (2025)&lt;/strong&gt; — &lt;strong&gt;IR Prediction + IR Explainer Agent&lt;/strong&gt; - A combination of machine learning and an LLM-based explainer to estimate metabolic risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 4 (2025)&lt;/strong&gt; — &lt;strong&gt;Personal Health Agent (PHA)&lt;/strong&gt; - A multi-agent system where different AI “roles” collaborate — data analyst, coach, and domain expert.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blog 5 (My Project, 2025)&lt;/strong&gt; - My own proof-of-concept that mixes ideas from all four systems to create a unified health agent architecture. My goal is to keep everything straightforward, even if someone is reading about AI for the first time.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Why This Topic Matters (and What I Hope You’ll Learn)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Most of us don’t think much about our health until something feels wrong. But our wearables are quietly tracking us every day — our sleep, heart rate, movement, and even stress signals. That means they’re collecting clues long before we ever feel anything.&lt;/p&gt;

&lt;p&gt;AI can turn those clues into something meaningful by noticing patterns we might miss, predicting early risks, explaining things in plain English, and even giving small suggestions that feel personal. To me, this makes health feel more understandable and less like a set of random numbers.&lt;/p&gt;

&lt;p&gt;Through this series, I want to share what I learned about these systems in a simple, relatable way. I’ll talk about how wearables work with AI, how different models make sense of health data, why LLMs and multi-agent systems matter, where the ethical issues show up, and how these ideas connect to real projects.&lt;/p&gt;

&lt;p&gt;I’m writing as a student — sharing what made sense to me, what confused me at first, and what finally “clicked.”  And at the end of the series, I’ll also walk through my own proof-of-concept project where I combine everything I learned into one architecture.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;10. References&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;PH-LLM: A Personal Health LLM for Sleep &amp;amp; Fitness Coaching&lt;br&gt;
Nature Medicine (2025)&lt;br&gt;
&lt;a href="https://www.nature.com/articles/s41591-025-03888-0" rel="noopener noreferrer"&gt;https://www.nature.com/articles/s41591-025-03888-0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PHIA: Transforming Wearable Data into Health Insights Using LLM Agents&lt;br&gt;
Google Research Blog (2024)&lt;br&gt;
&lt;a href="https://research.google/blog/advancing-personal-health-and-wellness-insights-with-ai/" rel="noopener noreferrer"&gt;https://research.google/blog/advancing-personal-health-and-wellness-insights-with-ai/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SHARP Framework: Principles for Building Health &amp;amp; Wellness LLMs&lt;br&gt;
Google (2025)&lt;br&gt;
&lt;a href="https://services.google.com/fh/files/blogs/winslow_2025_sharp_framework.pdf" rel="noopener noreferrer"&gt;https://services.google.com/fh/files/blogs/winslow_2025_sharp_framework.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Insulin Resistance Prediction From Wearables + Routine Blood Biomarkers&lt;br&gt;
arXiv (2025)&lt;br&gt;
&lt;a href="https://arxiv.org/pdf/2505.03784" rel="noopener noreferrer"&gt;https://arxiv.org/pdf/2505.03784&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Personal Health Agent (PHA): Multi-Agent System for Data + Coaching + Expertise&lt;br&gt;
arXiv (2025)&lt;br&gt;
&lt;a href="https://arxiv.org/pdf/2508.20148" rel="noopener noreferrer"&gt;https://arxiv.org/pdf/2508.20148&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>google</category>
      <category>llm</category>
      <category>health</category>
      <category>ai</category>
    </item>
    <item>
      <title>Nested Learning — My Reflections on a Model That Learns How to Learn</title>
      <dc:creator>Mitansh Gor</dc:creator>
      <pubDate>Mon, 17 Nov 2025 02:57:13 +0000</pubDate>
      <link>https://dev.to/mitanshgor/nested-learning-my-reflections-on-a-model-that-learns-how-to-learn-14b5</link>
      <guid>https://dev.to/mitanshgor/nested-learning-my-reflections-on-a-model-that-learns-how-to-learn-14b5</guid>
      <description>&lt;p&gt;I recently came across a paper called &lt;a href="https://research.google/blog/introducing-nested-learning-a-new-ml-paradigm-for-continual-learning/" rel="noopener noreferrer"&gt;&lt;strong&gt;Nested Learning: The Illusion of Deep Learning&lt;/strong&gt;&lt;/a&gt; by Behrouz and the team — the same researchers behind Titans and Atlas. It really caught my attention because it challenges what we usually think “deep learning” means. The paper says that depth in neural networks isn’t just about stacking layers — it’s about how many layers of learning the system can apply to itself. Instead of just updating weights, this model learns how to improve its own learning process.&lt;/p&gt;

&lt;p&gt;While reading it, I realized this isn’t just another optimization trick. It actually feels like a glimpse into what real intelligence could be — an AI that doesn’t just react but reflects, improves, and evolves how it learns over time. The authors even built a prototype called Hope, a model that modifies itself using feedback, learning not just what to learn but how to learn better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65zccs9kcg5k6ilukwrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65zccs9kcg5k6ilukwrf.png" alt="LearningToLearn" width="389" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Take on the Problems in Deep Learning and Transformers
&lt;/h2&gt;

&lt;p&gt;Today’s deep learning systems — even transformers — are strong but still limited in how they actually learn.&lt;/p&gt;

&lt;p&gt;Neural networks are called “deep” because of their layers, but their learning is flat — one optimizer like Adam or SGD updates everything the same way. Once training ends, the model stops learning, like a student who graduates and never studies again. :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5sr0zxhnevjaum8ho0v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5sr0zxhnevjaum8ho0v.png" alt="contextWindow" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Transformers improved context handling, but they only have short-term memory. They remember what’s inside their context window and forget the rest. Even if I teach GPT something new, it won’t remember it next time — its knowledge is frozen.&lt;/p&gt;

&lt;p&gt;To me, that’s what makes this paper exciting. It explores real, continuous learning, where models don’t just perform tasks but actually grow and evolve from their experiences — more like how the human brain learns over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the Human Brain Actually Learns
&lt;/h2&gt;

&lt;p&gt;When I compared this idea to how our brain works, the difference was clear. The brain doesn’t just store facts — it keeps updating how it learns from every experience. Each new moment changes not only what we know but how we learn next time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frc2xjpat5qyf0uesc61o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frc2xjpat5qyf0uesc61o.png" alt="brain" width="706" height="726"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like when I study late and remember less, my brain quietly adjusts — it learns how to learn better. We also have different kinds of memory: fast, short-term memory for quick thoughts and slow, long-term memory for what truly matters.&lt;/p&gt;

&lt;p&gt;What’s amazing is that all this happens at different speeds — reflexes form instantly, habits take time. That’s what makes our learning flexible and self-improving. This paper helped me realize that real intelligence isn’t just about storing knowledge — it’s about systems that can adapt the way they adapt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Real Intelligence Learns at Many Speeds
&lt;/h2&gt;

&lt;p&gt;“Nested Learning” mirrors the way our brain learns at multiple speeds. In real life, not all learning happens instantly — some lessons come from quick feedback, and others sink in over time through reflection and repetition.&lt;/p&gt;

&lt;p&gt;For example, when I make a mistake in code, I fix it fast — that’s short-term learning. But when I notice a pattern of mistakes across projects and change how I approach debugging, that’s slow, higher-order learning. My brain is basically nesting layers of learning, one inside another.&lt;/p&gt;

&lt;p&gt;This is exactly what the paper argues AI should do. Instead of having one rigid update rule for all situations, it should have systems that operate on different timescales — fast ones for reacting to the present and slow ones for improving how it learns in the future. Real intelligence, human or artificial, grows when it can &lt;em&gt;learn fast, remember slow, and keep adjusting both.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7cf72h9sp4dz83sq58w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7cf72h9sp4dz83sq58w.png" alt="levelBRain" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Optimizers Are Still “Shallow”
&lt;/h2&gt;

&lt;p&gt;One part that stood out to me was how the paper calls our current optimizers “shallow.” At first, that sounded odd — optimizers like Adam or SGD are what make models learn, right? But the point is deeper: they only operate at one level. They adjust the weights, but they never learn &lt;em&gt;how to optimize better&lt;/em&gt; on their own.&lt;/p&gt;

&lt;p&gt;Think about it like this — an optimizer is a rulebook. It says, “If error is high, change parameters this way.” That rule never changes, no matter how the model behaves or what patterns it encounters. It doesn’t evolve. It’s like a student who keeps using the same study method forever, even when it stops working.&lt;/p&gt;

&lt;p&gt;Nested Learning challenges that. It treats the optimizer as something that can &lt;em&gt;learn from its own history&lt;/em&gt; — almost like giving the optimizer memory and awareness. So instead of being a fixed rule, it becomes a learner itself. That’s why normal optimizers are called “shallow” — they only see one layer of the learning process, while true intelligence needs many.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Nested Learning Really Means
&lt;/h2&gt;

&lt;p&gt;When I finally got to the main idea — Nested Learning — it clicked for me that this isn’t just about deeper networks, but deeper &lt;em&gt;learning loops.&lt;/em&gt; Normally, a model learns by updating its parameters once per round. But in Nested Learning, there are multiple layers of learning stacked inside each other, each operating at its own level. &lt;/p&gt;

&lt;p&gt;The paper calls these “levels.”&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Level 1&lt;/strong&gt; is the fast learner — it adjusts to new data right away.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Level 2&lt;/strong&gt; is slower — it learns how well Level 1 is learning and changes its strategy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Level 3 and beyond&lt;/strong&gt; keep zooming out, letting the model reflect on its own updates and tweak the process itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxenaeptaijj1ljete540.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxenaeptaijj1ljete540.png" alt="levelsLearning" width="800" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc5wn947001ly0ew6abyi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc5wn947001ly0ew6abyi.png" alt="nestedLearning" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s like having a mind inside a mind inside a mind — each layer watching and improving the one below. What makes it powerful is that it never stops at one rule; it can always find a better way to learn. I realized that’s what makes it feel almost human — because that’s how we grow too, by not just learning facts, but by constantly refining &lt;em&gt;how&lt;/em&gt; we learn them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of Associative Memory
&lt;/h2&gt;

&lt;p&gt;In this paper, associative memory is what allows the model to connect surprise signals over time. Each time it encounters something unexpected, it doesn’t just correct the output; it stores that “surprise” pattern and learns from how surprises evolve. So instead of forgetting past mistakes, it builds a history of how it has been wrong before — and uses that as context for new learning.&lt;/p&gt;

&lt;p&gt;I liked how this turns memory from a passive storage system into an active, learning part of the network. It’s not just remembering data; it’s remembering &lt;em&gt;how learning felt last time.&lt;/em&gt; That’s what makes the system more adaptive and self-improving, just like how human intuition forms through repeated experiences.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsc3ap0y9ran5cvszl20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsc3ap0y9ran5cvszl20.png" alt="associativeMemory" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HOPE — The Model That Learns to Learn
&lt;/h2&gt;

&lt;p&gt;The paper introduces a model called &lt;strong&gt;HOPE (Hierarchical Optimizing Processing Ensemble)&lt;/strong&gt;, and it really ties everything together. HOPE is basically the first real example of Nested Learning in action. It builds on the older &lt;strong&gt;Titans architecture&lt;/strong&gt;, which was already designed for smart memory management — storing “surprising” experiences and forgetting the rest. But Titans could only update its parameters in two layers, which meant it was still limited to first-order learning.&lt;/p&gt;

&lt;p&gt;HOPE takes that concept and adds &lt;em&gt;self-modification&lt;/em&gt;. It doesn’t just store knowledge — it rewrites how it learns based on what it experiences. The more it learns, the better it gets at learning itself. That’s what makes it “hierarchical” — every layer is optimizing the one below it, creating an infinite loop of improvement.&lt;/p&gt;

&lt;p&gt;When I read that, it felt like looking at a prototype for true adaptive intelligence. HOPE doesn’t just grow its memory; it evolves its own way of thinking. It’s almost like the model is building its own brain architecture in real time — guided only by feedback and surprise.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2h73hnhrw783xirbqwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2h73hnhrw783xirbqwv.png" alt="hope" width="548" height="1064"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CMS — Learning Across Multiple Memory Speeds
&lt;/h2&gt;

&lt;p&gt;One of the coolest parts of the paper was the &lt;strong&gt;Continuum Memory System (CMS)&lt;/strong&gt;. This idea clicked with me right away because it’s inspired by how our brain manages memory at different speeds. We have fast, short-term memory for reacting to the moment, and slower, long-term memory for storing what truly matters. CMS brings that same principle to AI.&lt;/p&gt;

&lt;p&gt;In HOPE, CMS creates layers of memory that operate on different time scales. Fast memory reacts instantly to new data, slow memory holds onto stable knowledge, and middle layers balance both. The system learns what to keep, what to adapt, and what to forget — automatically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbwdvohd05ptemienwye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbwdvohd05ptemienwye.png" alt="cms" width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This makes the model more flexible and less likely to “forget” old knowledge when it learns something new, solving a big problem in continual learning. For me, CMS felt like giving the model an actual sense of &lt;em&gt;time&lt;/em&gt; — letting it learn short-term lessons without losing its long-term wisdom. It’s memory that grows, refines, and stays balanced, just like ours.&lt;/p&gt;

&lt;h2&gt;
  
  
  From Titans to HOPE — How the Architecture Evolved
&lt;/h2&gt;

&lt;p&gt;Before HOPE came along, there was the &lt;strong&gt;Titans architecture&lt;/strong&gt;, which was already an interesting idea. Titans worked like a long-term memory system for AI — it didn’t try to remember everything, only what was &lt;em&gt;surprising&lt;/em&gt;. Whenever the model saw something that didn’t match its expectations, it marked that as “important” and stored it. This made Titans good at keeping rare or unexpected experiences while forgetting routine ones, kind of like how our brain remembers unusual events more vividly than daily habits.  &lt;/p&gt;

&lt;p&gt;But Titans had a big limitation — it could only learn at &lt;strong&gt;two levels&lt;/strong&gt;. It could store knowledge (Level 1) and slightly adjust how it stored it (Level 2), but it couldn’t modify its own learning process. It was stuck with fixed update rules, so even though its memory was smart, its way of learning stayed static.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11ji4gmdtjpf0zooj1ta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11ji4gmdtjpf0zooj1ta.png" alt="Titan" width="800" height="1218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s where &lt;strong&gt;HOPE (Hierarchical Optimizing Processing Ensemble)&lt;/strong&gt; came in as the next step. HOPE keeps Titans’ “surprise-based memory,” but adds &lt;strong&gt;self-modification&lt;/strong&gt; — meaning it can change how it learns over time. Instead of just remembering, it &lt;em&gt;reflects&lt;/em&gt; on how it learned and improves that process.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg95ycli6qj5dfgutnrh8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg95ycli6qj5dfgutnrh8.png" alt="Hope" width="756" height="1266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Titans learns &lt;em&gt;what&lt;/em&gt; to remember.
&lt;/li&gt;
&lt;li&gt;HOPE learns &lt;em&gt;how&lt;/em&gt; to learn better next time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This shift from reactive memory (Titans) to reflective learning (HOPE) is what made the architecture truly recursive — an AI that can not only adapt but evolve its own learning rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Takes on the Paper
&lt;/h2&gt;

&lt;p&gt;This paper made me rethink what “deep learning” really means. It’s not just about adding layers — it’s about adding &lt;em&gt;levels of learning.&lt;/em&gt; I liked how it pushed the idea that intelligence should evolve, not just perform.&lt;/p&gt;

&lt;p&gt;What stood out to me was the mindset shift. Instead of models that just learn tasks, it showed a system that learns &lt;em&gt;how to learn better.&lt;/em&gt; That’s the kind of loop real intelligence needs — self-awareness in its own process.&lt;/p&gt;

&lt;p&gt;I also liked the balance between fast and slow learning. It reminded me of how humans think — reacting quickly to new events while slowly refining long-term habits. The whole idea felt less like training a model and more like nurturing an evolving mind.&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>google</category>
      <category>nestedlearning</category>
      <category>hope</category>
    </item>
  </channel>
</rss>
