Skip to content

Commit

Permalink
deploy: b796d94
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Feb 9, 2024
1 parent 89c75f3 commit 33a9d7a
Show file tree
Hide file tree
Showing 51 changed files with 295 additions and 293 deletions.
32 changes: 17 additions & 15 deletions S21_sorter_state.html
Original file line number Diff line number Diff line change
Expand Up @@ -700,22 +700,24 @@ <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
$<span 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</p>
<div class="math notranslate nohighlight">
\[
F_X(\alpha) = P(X \leq \alpha)
\)</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.
\]</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.
In the case of discrete random variables,
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">\(
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">
\[
F_X(\alpha) = \sum_{x_i \leq \alpha} P(x_i) = \sum_{i=0}^{k-1} P(x_i)
\)</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$,
\]</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>,
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 @@ -812,7 +814,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/097574b236056cbfdb69aa99f151670eec9d1bef574293520c5d206c421796f0.png" src="_images/097574b236056cbfdb69aa99f151670eec9d1bef574293520c5d206c421796f0.png" />
<img alt="_images/8eebbdcf2adff3f5f5a8af4f43e97e668c595e115b45e58db91e06a9ce21635a.png" src="_images/8eebbdcf2adff3f5f5a8af4f43e97e668c595e115b45e58db91e06a9ce21635a.png" />
</div>
</div>
<p>Of course, GTSAM has all this machinery built-in:</p>
Expand Down Expand Up @@ -883,7 +885,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/9c8f43b1109136336f9e0123309d1cb5c0ac563998d8e5b6b7ec3f27d76a9d72.svg" src="_images/9c8f43b1109136336f9e0123309d1cb5c0ac563998d8e5b6b7ec3f27d76a9d72.svg" /></div>
<img alt="_images/bf4adf3e1828e76fe4c81770566d20620857a2a5d48673a3aa052b56d24f963e.svg" src="_images/bf4adf3e1828e76fe4c81770566d20620857a2a5d48673a3aa052b56d24f963e.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/1168e2a0b2edb22262fc74eb6675dc212a75b3952c72a27bda187f472dd241c3.png" src="_images/1168e2a0b2edb22262fc74eb6675dc212a75b3952c72a27bda187f472dd241c3.png" />
<img alt="_images/37a7e42cddcebaa8a89b9c124b26684ecb1c3ce4c0337acbc85755bf4fddfc56.png" src="_images/37a7e42cddcebaa8a89b9c124b26684ecb1c3ce4c0337acbc85755bf4fddfc56.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>199.71582792081006
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>199.5991509963286
</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>2467.7996981732754
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2619.721677509057
</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>2467.7996981732754
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2619.721677509057
</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>49.6769533906144
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>51.18321675616976
</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/e235f8f9a72d9d62846093c369e034d05bdcc47c70a0b75006b21fded799b3ae.png" src="_images/e235f8f9a72d9d62846093c369e034d05bdcc47c70a0b75006b21fded799b3ae.png" />
<img alt="_images/913c4eb78733f33354575fb183efbf728dc04add5dc163e015ef238d6917e2af.png" src="_images/913c4eb78733f33354575fb183efbf728dc04add5dc163e015ef238d6917e2af.png" />
</div>
</div>
</section>
Expand Down
4 changes: 3 additions & 1 deletion S35_vacuum_decision.html
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,9 @@ <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
V(Hallway) ~ 97.37
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>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
36 changes: 16 additions & 20 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, 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)]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(0, 3, 0, 10.0), (0, 3, 3, 0.0), (3, 0, 3, 0.0), (3, 3, 3, 0.0), (3, 1, 4, 0.0), (4, 1, 4, 0.0), (4, 1, 4, 0.0), (4, 3, 4, 0.0), (4, 0, 3, 0.0), (3, 1, 3, 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([[31., 25., 23., 30.],
[29., 20., 17., 14.],
[32., 31., 34., 25.],
[29., 27., 25., 32.],
[25., 14., 20., 16.]])
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>array([[30., 20., 16., 32.],
[21., 19., 18., 25.],
[27., 30., 32., 22.],
[29., 28., 27., 24.],
[25., 21., 30., 23.]])
</pre></div>
</div>
</div>
Expand All @@ -567,7 +567,7 @@ <h2><span class="section-number">3.6.2. </span>Model-based Reinforcement Learnin
[[1. 0. 0. 0. 0. ]
[0.2 0.8 0. 0. 0. ]
[1. 0. 0. 0. 0. ]
[0.27 0. 0. 0.73 0. ]]
[0.25 0. 0. 0.75 0. ]]
</pre></div>
</div>
</div>
Expand All @@ -587,14 +587,10 @@ <h2><span class="section-number">3.6.2. </span>Model-based Reinforcement Learnin
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]]
estimate:
[[ 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]]
[[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]
[10. 0. 0. 0. 0.]]
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -652,11 +648,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>[[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]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[80.89327579 69.0043262 79.87752133 75.85025115]
[79.0357136 67.63101342 63.71690915 57.3717993 ]
[54.77782833 63.57900665 53.09007122 53.98443739]
[55.3238737 57.14596364 73.32901317 58.17808793]
[61.19094688 57.79394492 65.27580983 57.71790509]]
</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/af5942501ee14b80d8390fe967ea6b5997cd0ef8ac4f064dd16837ceeb211cdb.png" src="_images/af5942501ee14b80d8390fe967ea6b5997cd0ef8ac4f064dd16837ceeb211cdb.png" />
<img alt="_images/080275d9b1ca2aa6614175b196708ca28d2fc5190bec7a1d7ed190c2c03eadec.png" src="_images/080275d9b1ca2aa6614175b196708ca28d2fc5190bec7a1d7ed190c2c03eadec.png" />
</div>
</div>
</section>
Expand Down
28 changes: 14 additions & 14 deletions S44_logistics_perception.html
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,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 19.6 s, sys: 5.32 ms, total: 19.6 s
Wall time: 19.6 s
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 20.2 s, sys: 1.15 ms, total: 20.2 s
Wall time: 20.2 s
</pre></div>
</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.8 s, sys: 69 µs, total: 6.8 s
Wall time: 6.8 s
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 6.99 s, sys: 0 ns, total: 6.99 s
Wall time: 6.99 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/aea467b2415676db188fa5f9ea4b7b4433890f022276f93f9d7783c9cbb3d7d8.png" src="_images/aea467b2415676db188fa5f9ea4b7b4433890f022276f93f9d7783c9cbb3d7d8.png" />
<img alt="_images/846180a00938551d346f73e29b7aae9e7dbf7f505232962525e8d342cc7299d2.png" src="_images/846180a00938551d346f73e29b7aae9e7dbf7f505232962525e8d342cc7299d2.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/c892f2ae627cd83ba03eedbf63085fa727d60feadccdf52bca24d0e7542e2530.png" src="_images/c892f2ae627cd83ba03eedbf63085fa727d60feadccdf52bca24d0e7542e2530.png" />
<img alt="_images/f127af91a1cef7d8ee8c404b8b6774524a694c4145ba9d5176d77119f36801ed.png" src="_images/f127af91a1cef7d8ee8c404b8b6774524a694c4145ba9d5176d77119f36801ed.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/dc1c406f79dad6e5e6a75ced9a6b17d7046346dab017eb2c34f7888927b69d11.png" src="_images/dc1c406f79dad6e5e6a75ced9a6b17d7046346dab017eb2c34f7888927b69d11.png" />
<img alt="_images/136f8fa41744d6121f9c8c9741d6f509d0cc1ccf97eb1234d3a6559903b4669a.png" src="_images/136f8fa41744d6121f9c8c9741d6f509d0cc1ccf97eb1234d3a6559903b4669a.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 439 ms, sys: 47 µs, total: 439 ms
Wall time: 438 ms
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 442 ms, sys: 31 µs, total: 442 ms
Wall time: 441 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/8ecc52ac924ed71d0b46dd9d5564421e35d38bf7d6c28ddccb77c01e7baa4073.png" src="_images/8ecc52ac924ed71d0b46dd9d5564421e35d38bf7d6c28ddccb77c01e7baa4073.png" />
<img alt="_images/852bf6a0873312565591e45de1c1500926c687ba7744292f7646967e8909e2ac.png" src="_images/852bf6a0873312565591e45de1c1500926c687ba7744292f7646967e8909e2ac.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/08a64e21eb394aad16c97aa29b0521a74a9024690413d416b260f0e90046ce63.png" src="_images/08a64e21eb394aad16c97aa29b0521a74a9024690413d416b260f0e90046ce63.png" />
<img alt="_images/30ccedfc9874e2e643e5a43375e2359b29c292a11d600861b409ed83fad7af2f.png" src="_images/30ccedfc9874e2e643e5a43375e2359b29c292a11d600861b409ed83fad7af2f.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/e5db3b8988db84210daea2c642dced76c8778e0df0d9c08e18e348458dcadea3.png" src="_images/e5db3b8988db84210daea2c642dced76c8778e0df0d9c08e18e348458dcadea3.png" />
<img alt="_images/35fc7463de67ad7c87a1f51161e48f5c2749596e4a3412aaeb7114519fe57d01.png" src="_images/35fc7463de67ad7c87a1f51161e48f5c2749596e4a3412aaeb7114519fe57d01.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 467 ms, sys: 0 ns, total: 467 ms
Wall time: 467 ms
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CPU times: user 487 ms, sys: 3.98 ms, total: 491 ms
Wall time: 490 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.32 s, sys: 0 ns, total: 2.32 s
Wall time: 2.31 s
CPU times: user 2.3 s, sys: 321 µs, total: 2.3 s
Wall time: 2.3 s
</pre></div>
</div>
</div>
Expand Down
Loading

0 comments on commit 33a9d7a

Please sign in to comment.