<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://machinelearning.subwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Bellman_equation_derivation</id>
	<title>Bellman equation derivation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://machinelearning.subwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Bellman_equation_derivation"/>
	<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;action=history"/>
	<updated>2026-10-13T20:09:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.2</generator>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2514&amp;oldid=prev</id>
		<title>IssaRice: /* Law of total probability */</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2514&amp;oldid=prev"/>
		<updated>2019-09-01T04:03:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Law of total probability&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:03, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For fixed event &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; with non-zero probability, the mapping &amp;lt;math&amp;gt;B \mapsto \Pr(B \mid A)&amp;lt;/math&amp;gt; is another valid probability measure. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In other words, define &lt;/del&gt;&amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A&amp;lt;/math&amp;gt; by &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) := \Pr(B \mid A)&amp;lt;/math&amp;gt; for all events &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Now the law of total probability for &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A&amp;lt;/math&amp;gt; states that &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) = \sum_{j=1}^n \Pr_A(B \mid C_j)\Pr_A(C_j)&amp;lt;/math&amp;gt;. We also have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For fixed event &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; with non-zero probability, the mapping &amp;lt;math&amp;gt;B \mapsto \Pr(B \mid A)&amp;lt;/math&amp;gt; is another valid probability measure&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, so the law of total probability also applies to it&lt;/ins&gt;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Define &lt;/ins&gt;&amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A&amp;lt;/math&amp;gt; by &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) := \Pr(B \mid A)&amp;lt;/math&amp;gt; for all events &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Now the law of total probability for &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A&amp;lt;/math&amp;gt; states that &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) = \sum_{j=1}^n \Pr_A(B \mid C_j)\Pr_A(C_j)&amp;lt;/math&amp;gt;. We also have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\Pr_A(B \mid C_j) = \frac{\Pr_A(B \cap C_j)}{\Pr_A(C_j)} = \frac{\Pr(B\cap C_j \mid A)}{\Pr(C_j\mid A)} = \frac{\Pr(B \cap C_j \cap A)/\Pr(A)}{\Pr(C_j \cap A)/\Pr(A)} = \frac{\Pr(B\cap (C_j\cap A))}{\Pr(C_j \cap A)} = \Pr(B \mid C_j,A)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\Pr_A(B \mid C_j) = \frac{\Pr_A(B \cap C_j)}{\Pr_A(C_j)} = \frac{\Pr(B\cap C_j \mid A)}{\Pr(C_j\mid A)} = \frac{\Pr(B \cap C_j \cap A)/\Pr(A)}{\Pr(C_j \cap A)/\Pr(A)} = \frac{\Pr(B\cap (C_j\cap A))}{\Pr(C_j \cap A)} = \Pr(B \mid C_j,A)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2513&amp;oldid=prev</id>
		<title>IssaRice: /* Law of total probability */</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2513&amp;oldid=prev"/>
		<updated>2019-09-01T04:01:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Law of total probability&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:01, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For fixed event &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; with non-zero probability, the mapping &amp;lt;math&amp;gt;B \mapsto \Pr(B \mid A)&amp;lt;/math&amp;gt; is another valid probability measure. In other words, define &amp;lt;math&amp;gt;\Pr_A&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\Pr_A(B) := \Pr(B \mid A)&amp;lt;/math&amp;gt; for all events &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Now the law of total probability for &amp;lt;math&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;P_A&lt;/del&gt;&amp;lt;/math&amp;gt; states that &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) = \sum_{j=1}^n \Pr_A(B \mid C_j)\Pr_A(C_j)&amp;lt;/math&amp;gt;. We also have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For fixed event &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; with non-zero probability, the mapping &amp;lt;math&amp;gt;B \mapsto \Pr(B \mid A)&amp;lt;/math&amp;gt; is another valid probability measure. In other words, define &amp;lt;math &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;display=&quot;inline&quot;&lt;/ins&gt;&amp;gt;\Pr_A&amp;lt;/math&amp;gt; by &amp;lt;math &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;display=&quot;inline&quot;&lt;/ins&gt;&amp;gt;\Pr_A(B) := \Pr(B \mid A)&amp;lt;/math&amp;gt; for all events &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Now the law of total probability for &amp;lt;math &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;display=&quot;inline&quot;&lt;/ins&gt;&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;\Pr_A&lt;/ins&gt;&amp;lt;/math&amp;gt; states that &amp;lt;math display=&quot;inline&quot;&amp;gt;\Pr_A(B) = \sum_{j=1}^n \Pr_A(B \mid C_j)\Pr_A(C_j)&amp;lt;/math&amp;gt;. We also have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\Pr_A(B \mid C_j) = \frac{\Pr_A(B \cap C_j)}{\Pr_A(C_j)} = \frac{\Pr(B\cap C_j \mid A)}{\Pr(C_j\mid A)} = \frac{\Pr(B \cap C_j \cap A)/\Pr(A)}{\Pr(C_j \cap A)/\Pr(A)} = \frac{\Pr(B\cap (C_j\cap A))}{\Pr(C_j \cap A)} = \Pr(B \mid C_j,A)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\Pr_A(B \mid C_j) = \frac{\Pr_A(B \cap C_j)}{\Pr_A(C_j)} = \frac{\Pr(B\cap C_j \mid A)}{\Pr(C_j\mid A)} = \frac{\Pr(B \cap C_j \cap A)/\Pr(A)}{\Pr(C_j \cap A)/\Pr(A)} = \frac{\Pr(B\cap (C_j\cap A))}{\Pr(C_j \cap A)} = \Pr(B \mid C_j,A)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2512&amp;oldid=prev</id>
		<title>IssaRice at 03:56, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2512&amp;oldid=prev"/>
		<updated>2019-09-01T03:56:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:56, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The core idea of the proof is to use the law of total probability to go from marginal to conditional probabilities, and then invoke the Markov assumption.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The core idea of the proof is to use the law of total probability to go from marginal to conditional probabilities, and then invoke the Markov assumption.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Law of total probability==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The law of total probability states that if &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is an event, and &amp;lt;math&amp;gt;C_1, \ldots, C_n&amp;lt;/math&amp;gt; are events that partition the sample space, then &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\Pr(B) = \sum_{j=1}^n \Pr(B \cap C_j) = \sum_{j=1}^n \Pr(B \mid C_j)\Pr(C_j)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is the basic trick of the proof; we keep conditioning on different things (actions, next states, rewards) and using the law of total probability.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is the basic trick of the proof; we keep conditioning on different things (actions, next states, rewards) and using the law of total probability.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Start of proof==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By definition, &amp;lt;math&amp;gt;v_\pi(s) = \mathbb E_\pi[G_t \mid S_t = s]&amp;lt;/math&amp;gt;. Now rewrite &amp;lt;math&amp;gt;G_t = R_{t+1} + \gamma G_{t+1}&amp;lt;/math&amp;gt; and use the linearity of expectation to get &amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s] + \gamma\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt;. From here, we can work separately with &amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt; for a while.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By definition, &amp;lt;math&amp;gt;v_\pi(s) = \mathbb E_\pi[G_t \mid S_t = s]&amp;lt;/math&amp;gt;. Now rewrite &amp;lt;math&amp;gt;G_t = R_{t+1} + \gamma G_{t+1}&amp;lt;/math&amp;gt; and use the linearity of expectation to get &amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s] + \gamma\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt;. From here, we can work separately with &amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt; for a while.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Simplifying expectation for reward term==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Using the law of total probability while conditioning over actions, we have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Using the law of total probability while conditioning over actions, we have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l50&quot;&gt;Line 50:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 56:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s] = \sum_a \pi(a\mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r \mid s,a) r&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\mathbb E_\pi[R_{t+1} \mid S_t=s] = \sum_a \pi(a\mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r \mid s,a) r&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Simplifying expression for return term==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now we do a similar series of steps for &amp;lt;math&amp;gt;\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt;. Conditioning over actions,&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now we do a similar series of steps for &amp;lt;math&amp;gt;\mathbb E_\pi[G_{t+1}\mid S_t = s]&amp;lt;/math&amp;gt;. Conditioning over actions,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 75:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details. I think &lt;/del&gt;the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt; (NOTE: Sutton and Barto&#039;s text seems to have a small error here, where they describe the Markovian property as &quot;That is, &lt;/del&gt;the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;probability &lt;/del&gt;of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;each possible value for &amp;lt;math&amp;gt;S_t&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;R_t&amp;lt;/math&amp;gt; depends only on the immediately preceding state and action, &amp;lt;math&amp;gt;S_{t-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;A_{t-1}&amp;lt;/math&amp;gt;, and, given them, not at all on earlier states and actions.&quot; -- the last part should probably say &quot;not at all on earlier states, actions, and rewards&quot;. Otherwise I&#039;m not sure how to prove that we can ignore the conditioning on &amp;lt;math&amp;gt;R_{t+1}=r&amp;lt;/math&amp;gt;). So &lt;/del&gt;this &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;section at &lt;/ins&gt;the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;end &lt;/ins&gt;of this &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;page&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) v_\pi(s&amp;#039;)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) v_\pi(s&amp;#039;)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Finishing the proof==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l78&quot;&gt;Line 78:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 88:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This completes the proof. I&amp;#039;m pretty confused why Sutton and Barto seem to think abbreviating all these steps without comment is a good idea.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This completes the proof. I&amp;#039;m pretty confused why Sutton and Barto seem to think abbreviating all these steps without comment is a good idea.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Using the Markov assumption==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt; (NOTE: Sutton and Barto&#039;s text seems to have a small error here, where they describe the Markovian property as &quot;That is, the probability of each possible value for &amp;lt;math&amp;gt;S_t&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;R_t&amp;lt;/math&amp;gt; depends only on the immediately preceding state and action, &amp;lt;math&amp;gt;S_{t-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;A_{t-1}&amp;lt;/math&amp;gt;, and, given them, not at all on earlier states and actions.&quot; -- the last part should probably say &quot;not at all on earlier states, actions, and rewards&quot;. Otherwise I&#039;m not sure how to prove that we can ignore the conditioning on &amp;lt;math&amp;gt;R_{t+1}=r&amp;lt;/math&amp;gt;). So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;See [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for a similar manipulation.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2511&amp;oldid=prev</id>
		<title>IssaRice at 03:41, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2511&amp;oldid=prev"/>
		<updated>2019-09-01T03:41:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:41, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details. I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt;. So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details. I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(NOTE: Sutton and Barto&#039;s text seems to have a small error here, where they describe the Markovian property as &quot;That is, the probability of each possible value for &amp;lt;math&amp;gt;S_t&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;R_t&amp;lt;/math&amp;gt; depends only on the immediately preceding state and action, &amp;lt;math&amp;gt;S_{t-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;A_{t-1}&amp;lt;/math&amp;gt;, and, given them, not at all on earlier states and actions.&quot; -- the last part should probably say &quot;not at all on earlier states, actions, and rewards&quot;. Otherwise I&#039;m not sure how to prove that we can ignore the conditioning on &amp;lt;math&amp;gt;R_{t+1}=r&amp;lt;/math&amp;gt;)&lt;/ins&gt;. So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2510&amp;oldid=prev</id>
		<title>IssaRice at 03:38, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2510&amp;oldid=prev"/>
		<updated>2019-09-01T03:38:25Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:38, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details. I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) =&lt;/del&gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt;. So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details. I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt;. So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2509&amp;oldid=prev</id>
		<title>IssaRice at 03:37, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2509&amp;oldid=prev"/>
		<updated>2019-09-01T03:37:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:37, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. I think the following works: It suffices to show &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Conditioning over actions in the &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt; timestep, we have &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) =\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;. But the action is chosen by the policy, which depends only on the state, so &amp;lt;math&amp;gt;\Pr(A_{t+1}=a&#039; \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \pi(a&#039; \mid s&#039;)&amp;lt;/math&amp;gt;. As for &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;, recall that &amp;lt;math&amp;gt;G_{t+1} = R_{t+2} + R_{t+3} + \cdots&amp;lt;/math&amp;gt; so has only rewards starting on timestep &amp;lt;math&amp;gt;t+2&amp;lt;/math&amp;gt;. Since we are working with an MDP, the environment&#039;s dynamics are completely determined by the state and action on timestep &amp;lt;math&amp;gt;t+1&amp;lt;/math&amp;gt;, i.e. on &amp;lt;math&amp;gt;s&#039;&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a&#039;&amp;lt;/math&amp;gt;. So this is equal to &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;. Thus we have &amp;lt;math&amp;gt;\sum_{a&#039;} \Pr(G_{t+1} = g \mid A_{t+1}=a&#039;, S_{t+1}=s&#039;)\pi(a&#039;\mid s&#039;)&amp;lt;/math&amp;gt;. Now we can reverse the conditionalization, i.e. we marginalize to obtain &amp;lt;math&amp;gt;\Pr(G_{t+1} = g \mid S_{t+1}=s&#039;)&amp;lt;/math&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So we end up with&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2508&amp;oldid=prev</id>
		<title>IssaRice at 02:09, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2508&amp;oldid=prev"/>
		<updated>2019-09-01T02:09:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:09, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l75&quot;&gt;Line 75:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 75:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;\begin{align}v_\pi(s) &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;) \\ &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) [r + \gamma v_\pi(s&#039;)]\end{align}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;&amp;lt;math&amp;gt;\begin{align}v_\pi(s) &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;) \\ &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) [r + \gamma v_\pi(s&#039;)]\end{align}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This completes the proof. I&#039;m pretty confused why Sutton and Barto seem to think abbreviating all these steps without comment is a good idea.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2507&amp;oldid=prev</id>
		<title>IssaRice at 02:08, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2507&amp;oldid=prev"/>
		<updated>2019-09-01T02:08:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:08, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l75&quot;&gt;Line 75:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 75:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;\begin{align}&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;v_pi&lt;/del&gt;(s) &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;) \\ &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) [r + \gamma v_\pi(s&#039;)]\end{align}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;\begin{align}&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;v_\pi&lt;/ins&gt;(s) &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;) \\ &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) [r + \gamma v_\pi(s&#039;)]\end{align}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2506&amp;oldid=prev</id>
		<title>IssaRice at 02:08, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2506&amp;oldid=prev"/>
		<updated>2019-09-01T02:08:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:08, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l75&quot;&gt;Line 75:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 75:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So now we have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;v_pi(s) = \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;\begin{align}&lt;/ins&gt;v_pi(s) &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;&lt;/ins&gt;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;) &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;\\ &amp;amp;= \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) [r + \gamma v_\pi(s&#039;)]\end{align}&lt;/ins&gt;&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2505&amp;oldid=prev</id>
		<title>IssaRice at 02:07, 1 September 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=Bellman_equation_derivation&amp;diff=2505&amp;oldid=prev"/>
		<updated>2019-09-01T02:07:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:07, 1 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l67&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&amp;#039;,r} p(s&amp;#039;,r\mid s,a) \sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&amp;#039;, R_{t+1}=r, A_t=a, S_t=s)&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is basically what we want, except we want to say that &amp;lt;math&amp;gt;\sum_g g \Pr(G_{t+1} = g \mid S_{t+1}=s&#039;, R_{t+1}=r, A_t=a, S_t=s) = \mathbb E_\pi[G_{t+1} \mid S_{t+1}=s&#039;]&amp;lt;/math&amp;gt;, since the latter expression equals &amp;lt;math&amp;gt;v_\pi(s&#039;)&amp;lt;/math&amp;gt;. Thankfully, we can say this, because of the Markov assumption. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Actually proving this is a little complicated; see [https://math.stackexchange.com/questions/3143290/writing-action-value-function-in-terms-of-state-value-function-for-a-markov-deci this question] for some details.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;So we end up with&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&amp;lt;math&amp;gt;\sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;)&amp;lt;/math&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;So now we have&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;math&amp;gt;v_pi(s) = \sum_a \pi(a\mid s) \sum_{s&#039;,r} p(s&#039;,r \mid s,a) r + \gamma \sum_a \pi(a \mid s) \sum_{s&#039;,r} p(s&#039;,r\mid s,a) v_\pi(s&#039;)&amp;lt;/math&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
</feed>