Skip to content

Commit

Permalink
deploy: d4c145b
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Feb 9, 2024
1 parent 834a953 commit 89c75f3
Show file tree
Hide file tree
Showing 51 changed files with 295 additions and 298 deletions.
32 changes: 15 additions & 17 deletions S21_sorter_state.html
Original file line number Diff line number Diff line change
Expand Up @@ -700,24 +700,22 @@ <h3><span class="section-number">2.1.5.1. </span>Cumulative Distribution Functio
We will more carefully introduce the notion of a discrete random variable in Section 2.2, but for now it
is sufficient to know that a discrete random variable takes a value from a countable set,
each of which is assigned a probability value.
For a random variable <span class="math notranslate nohighlight">\(X\)</span>, the CDF for <span class="math notranslate nohighlight">\(X\)</span> is denoted by <span class="math notranslate nohighlight">\(F_X\)</span>, and is defined as</p>
<div class="math notranslate nohighlight">
\[
For a random variable <span class="math notranslate nohighlight">\(X\)</span>, the CDF for <span class="math notranslate nohighlight">\(X\)</span> is denoted by <span class="math notranslate nohighlight">\(F_X\)</span>, and is defined as
$<span class="math notranslate nohighlight">\(
F_X(\alpha) = P(X \leq \alpha)
\]</div>
<p>It follows immediately that <span class="math notranslate nohighlight">\(0 \leq F_X(\alpha) \leq 1\)</span>,
since <span class="math notranslate nohighlight">\(F_X(\alpha)\)</span> is itself a probability.
\)</span><span class="math notranslate nohighlight">\(
It follows immediately that \)</span>0 \leq F_X(\alpha) \leq 1<span class="math notranslate nohighlight">\(,
since \)</span>F_X(\alpha)<span class="math notranslate nohighlight">\( is itself a probability.
In the case of discrete random variables,
say <span class="math notranslate nohighlight">\(X \in \{ x_0, \dots x_{n-1}\}\)</span>, we can compute the CDF
<span class="math notranslate nohighlight">\(F_X(\alpha)\)</span> by summing the probabilities assigned
to all <span class="math notranslate nohighlight">\(x_i \leq \alpha\)</span></p>
<div class="math notranslate nohighlight">
\[
say \)</span>X \in { x_0, \dots x_{n-1}}<span class="math notranslate nohighlight">\(, we can compute the CDF
\)</span>F_X(\alpha)<span class="math notranslate nohighlight">\( by summing the probabilities assigned
to all \)</span>x_i \leq \alpha<span class="math notranslate nohighlight">\(
\)</span><span class="math notranslate nohighlight">\(
F_X(\alpha) = \sum_{x_i \leq \alpha} P(x_i) = \sum_{i=0}^{k-1} P(x_i)
\]</div>
<p>in which the rightmost summation follows if we choose <span class="math notranslate nohighlight">\(k\)</span> such that <span class="math notranslate nohighlight">\(x_{k-1} \leq \alpha &lt; x_k\)</span>.
The terminology <em>Cumulative Distribution Function</em> is due to the fact that <span class="math notranslate nohighlight">\(F_X(\alpha)\)</span>
is the accumulated probability assigned to all outcomes less than or equal to <span class="math notranslate nohighlight">\(\alpha\)</span>,
\)</span><span class="math notranslate nohighlight">\(
in which the rightmost summation follows if we choose \)</span>k<span class="math notranslate nohighlight">\( such that \)</span>x_{k-1} \leq \alpha &lt; x_k<span class="math notranslate nohighlight">\(.
The terminology *Cumulative Distribution Function* is due to the fact that \)</span>F_X(\alpha)<span class="math notranslate nohighlight">\(
is the accumulated probability assigned to all outcomes less than or equal to \)</span>\alpha$,
which is apparent in these summation expressions.</p>
<p>But what does this have to do with generating samples from our distribution on categories?
The idea is simple: we can generate <span class="math notranslate nohighlight">\(x\sim U(0,1)\)</span>, and a CDF takes on values in the
Expand Down Expand Up @@ -814,7 +812,7 @@ <h3><span class="section-number">2.1.5.2. </span>Example<a class="headerlink" hr
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/c7dc844bf0bc2c2504a55901fd204564725035b23ed7d1764b00e9cbb8c87b91.png" src="_images/c7dc844bf0bc2c2504a55901fd204564725035b23ed7d1764b00e9cbb8c87b91.png" />
<img alt="_images/097574b236056cbfdb69aa99f151670eec9d1bef574293520c5d206c421796f0.png" src="_images/097574b236056cbfdb69aa99f151670eec9d1bef574293520c5d206c421796f0.png" />
</div>
</div>
<p>Of course, GTSAM has all this machinery built-in:</p>
Expand Down Expand Up @@ -885,7 +883,7 @@ <h2><span class="section-number">2.1.6. </span>GTSAM 101<a class="headerlink" hr
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/bff00db02039df0e59e0f1042b380d7327114345189d6b4787d77d502141b535.svg" src="_images/bff00db02039df0e59e0f1042b380d7327114345189d6b4787d77d502141b535.svg" /></div>
<img alt="_images/9c8f43b1109136336f9e0123309d1cb5c0ac563998d8e5b6b7ec3f27d76a9d72.svg" src="_images/9c8f43b1109136336f9e0123309d1cb5c0ac563998d8e5b6b7ec3f27d76a9d72.svg" /></div>
</div>
<p>Of course, it would be much nicer if we could print out these PMFs in a more readable format, that shows us a name for each variable as well as a pretty name for each. This is where the <code class="docutils literal notranslate"><span class="pre">Variables</span></code> class comes to the rescue. We actually defined a global variable at the top of this notebook, like so:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">VARIABLES</span> <span class="o">=</span> <span class="n">Variables</span><span class="p">()</span>
Expand Down
30 changes: 15 additions & 15 deletions S23_sorter_sensing.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions S24_sorter_perception.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions S26_sorter_learning.html
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ <h2><span class="section-number">2.6.3. </span>Fitting a Gaussian<a class="heade
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/cf46232233f3d523eba4af9d7dcf7eb322d8ee9bb5aeaebec7269ba10f08a2c9.png" src="_images/cf46232233f3d523eba4af9d7dcf7eb322d8ee9bb5aeaebec7269ba10f08a2c9.png" />
<img alt="_images/1168e2a0b2edb22262fc74eb6675dc212a75b3952c72a27bda187f472dd241c3.png" src="_images/1168e2a0b2edb22262fc74eb6675dc212a75b3952c72a27bda187f472dd241c3.png" />
</div>
</div>
<p>The sample mean is easy enough to compute with <code class="docutils literal notranslate"><span class="pre">np.mean</span></code> :</p>
Expand All @@ -776,7 +776,7 @@ <h2><span class="section-number">2.6.3. </span>Fitting a Gaussian<a class="heade
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>197.80988617492557
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>199.71582792081006
</pre></div>
</div>
</div>
Expand All @@ -788,7 +788,7 @@ <h2><span class="section-number">2.6.3. </span>Fitting a Gaussian<a class="heade
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2387.0831525246535
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2467.7996981732754
</pre></div>
</div>
</div>
Expand All @@ -805,7 +805,7 @@ <h2><span class="section-number">2.6.3. </span>Fitting a Gaussian<a class="heade
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2387.0831525246535
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2467.7996981732754
</pre></div>
</div>
</div>
Expand All @@ -819,7 +819,7 @@ <h2><span class="section-number">2.6.3. </span>Fitting a Gaussian<a class="heade
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>48.857784973580756
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>49.6769533906144
</pre></div>
</div>
</div>
Expand All @@ -838,7 +838,7 @@ <h3><span class="section-number">2.6.3.1. </span>Comparison<a class="headerlink"
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/5eb7ae3f5f412c838ce4a7205a2a3adfa84e68247ab96497fa64e4e6acf5ed6a.png" src="_images/5eb7ae3f5f412c838ce4a7205a2a3adfa84e68247ab96497fa64e4e6acf5ed6a.png" />
<img alt="_images/e235f8f9a72d9d62846093c369e034d05bdcc47c70a0b75006b21fded799b3ae.png" src="_images/e235f8f9a72d9d62846093c369e034d05bdcc47c70a0b75006b21fded799b3ae.png" />
</div>
</div>
</section>
Expand Down
4 changes: 1 addition & 3 deletions S35_vacuum_decision.html
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,7 @@ <h2><span class="section-number">3.5.7. </span>Approximating the Value Function<
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>V(Living Room) ~ 99.43
V(Kitchen) ~ 97.64
V(Office) ~ 84.74
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>V(Hallway) ~ 97.37
V(Hallway) ~ 97.37
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>V(Dining Room) ~ 85.89
Expand Down
38 changes: 21 additions & 17 deletions S36_vacuum_RL.html
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ <h2><span class="section-number">3.6.1. </span>Exploring to get Data<a class="he
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(0, 1, 0, 10.0), (0, 1, 1, 0.0), (1, 3, 4, 0.0), (4, 1, 4, 0.0), (4, 3, 4, 0.0), (4, 3, 4, 0.0), (4, 3, 4, 0.0), (4, 2, 1, 0.0), (1, 3, 4, 0.0), (4, 2, 1, 0.0)]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(0, 1, 0, 10.0), (0, 3, 3, 0.0), (3, 2, 3, 0.0), (3, 2, 0, 10.0), (0, 1, 1, 0.0), (1, 0, 0, 10.0), (0, 2, 0, 10.0), (0, 1, 1, 0.0), (1, 2, 1, 0.0), (1, 1, 1, 0.0)]
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -539,11 +539,11 @@ <h2><span class="section-number">3.6.2. </span>Model-based Reinforcement Learnin
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>array([[24., 28., 18., 32.],
[29., 35., 27., 34.],
[14., 19., 13., 12.],
[21., 28., 31., 21.],
[30., 25., 29., 29.]])
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>array([[31., 25., 23., 30.],
[29., 20., 17., 14.],
[32., 31., 34., 25.],
[29., 27., 25., 32.],
[25., 14., 20., 16.]])
</pre></div>
</div>
</div>
Expand All @@ -565,9 +565,9 @@ <h2><span class="section-number">3.6.2. </span>Model-based Reinforcement Learnin
[0.2 0. 0. 0.8 0. ]]
estimate:
[[1. 0. 0. 0. 0. ]
[0.18 0.82 0. 0. 0. ]
[0.2 0.8 0. 0. 0. ]
[1. 0. 0. 0. 0. ]
[0.28 0. 0. 0.72 0. ]]
[0.27 0. 0. 0.73 0. ]]
</pre></div>
</div>
</div>
Expand All @@ -587,10 +587,14 @@ <h2><span class="section-number">3.6.2. </span>Model-based Reinforcement Learnin
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]]
estimate:
[[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]]
[[ 1.00000000e+001 0.00000000e+000 0.00000000e+000 0.00000000e+000
0.00000000e+000]
[ 1.00000000e+001 0.00000000e+000 0.00000000e+000 -0.00000000e+000
0.00000000e+000]
[ 1.00000000e+001 -0.00000000e+000 0.00000000e+000 0.00000000e+000
-0.00000000e+000]
[ 1.00000000e+001 0.00000000e+000 1.42133826e+260 0.00000000e+000
0.00000000e+000]]
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -648,11 +652,11 @@ <h2><span class="section-number">3.6.3. </span>Model-free Reinforcement Learning
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[78.93020597 68.43790847 79.2265916 70.19747899]
[77.97001819 65.01556908 66.23088985 62.20487454]
[40.01926133 55.1184683 43.80518768 33.65701515]
[57.60159025 57.09919101 78.79383003 62.18317566]
[64.95435886 55.98356842 66.61619122 55.05141338]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[83.273198 73.08952516 86.00192344 73.49848611]
[77.14143103 69.9187055 66.31824233 59.75518534]
[47.20437059 66.96369199 51.34351647 46.89227101]
[57.64468437 65.14359693 83.84591378 73.67712325]
[74.41835221 61.00456667 69.33242999 58.58230069]]
</pre></div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion S41_logistics_state.html
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ <h2><span class="section-number">4.1.3. </span>A Sampling-based representation.<
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/4f21ebd353861c1d124c14b74b01f5ac7388d0a9ee78bcf9808f02b8388a0b65.png" src="_images/4f21ebd353861c1d124c14b74b01f5ac7388d0a9ee78bcf9808f02b8388a0b65.png" />
<img alt="_images/af5942501ee14b80d8390fe967ea6b5997cd0ef8ac4f064dd16837ceeb211cdb.png" src="_images/af5942501ee14b80d8390fe967ea6b5997cd0ef8ac4f064dd16837ceeb211cdb.png" />
</div>
</div>
</section>
Expand Down
26 changes: 13 additions & 13 deletions S44_logistics_perception.html
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ <h3><span class="section-number">4.4.3.2. </span>Warehouse Example<a class="head
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 19.6 s, sys: 0 ns, total: 19.6 s
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 19.6 s, sys: 5.32 ms, total: 19.6 s
Wall time: 19.6 s
</pre></div>
</div>
Expand Down Expand Up @@ -760,8 +760,8 @@ <h3><span class="section-number">4.4.3.2. </span>Warehouse Example<a class="head
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 6.79 s, sys: 1.12 ms, total: 6.79 s
Wall time: 6.79 s
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 6.8 s, sys: 69 µs, total: 6.8 s
Wall time: 6.8 s
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -856,7 +856,7 @@ <h3><span class="section-number">4.4.4.1. </span>The Prediction Step<a class="he
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/49ec6c0e0a6ed559b5410e2019659fdaf6fd3bf1cc6457e5c41c1a284d33420e.png" src="_images/49ec6c0e0a6ed559b5410e2019659fdaf6fd3bf1cc6457e5c41c1a284d33420e.png" />
<img alt="_images/aea467b2415676db188fa5f9ea4b7b4433890f022276f93f9d7783c9cbb3d7d8.png" src="_images/aea467b2415676db188fa5f9ea4b7b4433890f022276f93f9d7783c9cbb3d7d8.png" />
</div>
</div>
<p>As you can see the first component is chosen much more often, which is exactly what we expect.</p>
Expand Down Expand Up @@ -903,7 +903,7 @@ <h3><span class="section-number">4.4.4.3. </span>MCL Warehouse Example<a class="
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/4813fe7d1c0667fb57c2642b8bad7df9f11b5c33f67842e28fe6a60591c54773.png" src="_images/4813fe7d1c0667fb57c2642b8bad7df9f11b5c33f67842e28fe6a60591c54773.png" />
<img alt="_images/c892f2ae627cd83ba03eedbf63085fa727d60feadccdf52bca24d0e7542e2530.png" src="_images/c892f2ae627cd83ba03eedbf63085fa727d60feadccdf52bca24d0e7542e2530.png" />
</div>
</div>
<p>Compare this sampling-based representation with the Markov localization representation of the prior above, and note they represent the <em>same</em> density, but using vastly different representations. In fact, they also use vastly different resources: for Markov localization we used 5000 cells, and here we use 500 samples, each represented as a two-dimensional vector. In higher-dimensional state spaces this difference is even greater: what would happen if we wanted to represent orientation as well?</p>
Expand All @@ -919,7 +919,7 @@ <h3><span class="section-number">4.4.4.3. </span>MCL Warehouse Example<a class="
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/1f10cee2af65e9aac62430f7536896a072a1e1146b543aeae15efb04387a0c8f.png" src="_images/1f10cee2af65e9aac62430f7536896a072a1e1146b543aeae15efb04387a0c8f.png" />
<img alt="_images/dc1c406f79dad6e5e6a75ced9a6b17d7046346dab017eb2c34f7888927b69d11.png" src="_images/dc1c406f79dad6e5e6a75ced9a6b17d7046346dab017eb2c34f7888927b69d11.png" />
</div>
</div>
<p>Note that all samples close to the wall and/or the shelves have disappeared, as they have zero weight. All remaining samples have the same weight.</p>
Expand All @@ -938,8 +938,8 @@ <h3><span class="section-number">4.4.4.3. </span>MCL Warehouse Example<a class="
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 429 ms, sys: 3.89 ms, total: 433 ms
Wall time: 432 ms
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 439 ms, sys: 47 µs, total: 439 ms
Wall time: 438 ms
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -996,7 +996,7 @@ <h3><span class="section-number">4.4.4.4. </span>Adding Range Sensing<a class="h
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/cb35ed78b8c3043ea7bbe5670d0122e93281d31b2c440b3727472a9191bd593f.png" src="_images/cb35ed78b8c3043ea7bbe5670d0122e93281d31b2c440b3727472a9191bd593f.png" />
<img alt="_images/8ecc52ac924ed71d0b46dd9d5564421e35d38bf7d6c28ddccb77c01e7baa4073.png" src="_images/8ecc52ac924ed71d0b46dd9d5564421e35d38bf7d6c28ddccb77c01e7baa4073.png" />
</div>
</div>
<p>The first range measurement happens to be out of range, and we can see the effect on our estimate for the posterior <span class="math notranslate nohighlight">\(p(x_1|z_1)\)</span> quite clearly:</p>
Expand All @@ -1011,7 +1011,7 @@ <h3><span class="section-number">4.4.4.4. </span>Adding Range Sensing<a class="h
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/c845f8d520184ea04a61ac94fce7fe81bb56170b80864c6d9ed756e5c0b71c6f.png" src="_images/c845f8d520184ea04a61ac94fce7fe81bb56170b80864c6d9ed756e5c0b71c6f.png" />
<img alt="_images/08a64e21eb394aad16c97aa29b0521a74a9024690413d416b260f0e90046ce63.png" src="_images/08a64e21eb394aad16c97aa29b0521a74a9024690413d416b260f0e90046ce63.png" />
</div>
</div>
<p>As expected, the likelihood has “punched holes” around the beacons, because we <em>know</em> we cannot have been near them. When we combine this with the proximity OFF measurement, we improve our posterior even more:</p>
Expand All @@ -1024,7 +1024,7 @@ <h3><span class="section-number">4.4.4.4. </span>Adding Range Sensing<a class="h
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/732ddd26d39ee20437b3eaa77fba8aa4e0e781d5624378d143dbdc9ef20da686.png" src="_images/732ddd26d39ee20437b3eaa77fba8aa4e0e781d5624378d143dbdc9ef20da686.png" />
<img alt="_images/e5db3b8988db84210daea2c642dced76c8778e0df0d9c08e18e348458dcadea3.png" src="_images/e5db3b8988db84210daea2c642dced76c8778e0df0d9c08e18e348458dcadea3.png" />
</div>
</div>
<p>We are now ready to bring it all together by multiplying <em>two</em> likelihoods in every measurement update phase:</p>
Expand All @@ -1046,8 +1046,8 @@ <h3><span class="section-number">4.4.4.4. </span>Adding Range Sensing<a class="h
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 466 ms, sys: 0 ns, total: 466 ms
Wall time: 466 ms
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 467 ms, sys: 0 ns, total: 467 ms
Wall time: 467 ms
</pre></div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions S45_logistics_planning.html
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ <h2><span class="section-number">4.5.1. </span>Value Iteration in 2D<a class="he
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>after 86 iterations, error = 0.0
CPU times: user 2.26 s, sys: 0 ns, total: 2.26 s
Wall time: 2.26 s
CPU times: user 2.32 s, sys: 0 ns, total: 2.32 s
Wall time: 2.31 s
</pre></div>
</div>
</div>
Expand Down
Loading

0 comments on commit 89c75f3

Please sign in to comment.