diff --git a/kalman filter 1D.ipynb b/kalman filter 1D.ipynb index ec127c7..45f3240 100644 --- a/kalman filter 1D.ipynb +++ b/kalman filter 1D.ipynb @@ -7,23 +7,16 @@ "worksheets": [ { "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Introduction to Tracking" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ + "# Introduction to Tracking\n", "Let us begin with a simple problem. We have a dog friendly workspace, and so people bring their dogs to work. However, occasionally the dogs wander out of your office and down the halls. We want to be able to track them. So during a hackathon somebody created a little sonar sensor to attach to the dog's collar. It emits a signal, listens for the echo, and based on how quickly an echo comes back we can tell whether the dog is in front of an open doorway or not. It also senses when the dog walks, and reports in which direction the dog has moved. It connects to our network via wifi and sends an update once a second.\n", "\n", "I want to track my dog Simon, so I attach the device to his collar and then fire up Python, ready to try to write code to track him through the building. At first blush this may appear impossible. If I start listening to the sensor of Simon's collar I might read 'door', 'hall', 'hall', and so on. How can I use that information to determine where Simon is?\n", "\n", - "To keep the problem small, we will assume that there are only 10 positions in a single hallway to consider. The first position corresponds to the far left end of the corridor, and the last position to the far right. \n", + "To keep the problem small, we will assume that there are only 10 positions in a single hallway to consider, which we will number 0 to 9, where 1 is to the right of 0, 2 is to the right of 1, and so on. For reasons that will be clear later, we will also assume that the hallway is circular or rectangular. If you move right from position 9, you will be at position 0. \n", "\n", "When I begin listening to the sensor I have no reason to believe that Simon is at any particular position in the hallway. He is equally likely to be in any position. The probability that he is in each position is therefore $1/10$ \n", "\n", @@ -72,11 +65,14 @@ "input": [ "pos = array([0.333, 0.333, 0., 0., 0., 0., 0., 0., 0.333, 0.])\n", "\n", - "ax = plt.figure().gca()\n", - "x = np.arange(10)\n", - "ax.bar(x, pos)\n", - "plt.xticks(x+0.5, x)\n", - "plt.show()\n" + "def bar_plot(pos):\n", + " ax = plt.figure().gca()\n", + " x = np.arange(len(pos))\n", + " ax.bar(x, pos)\n", + " plt.xticks(x+0.5, x)\n", + " plt.show()\n", + "\n", + "bar_plot (pos)" ], "language": "python", "metadata": {}, @@ -86,11 +82,11 @@ "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEACAYAAAC57G0KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF/BJREFUeJzt3WFsE+fhx/GfWTyhwb9AaAbBzuRCUmwgMR4OEa2iuVMg\ngqkRydiUwko1MhYxoWpTpU57NegL1mxCGix7ESHohIogL7oRtkLGIvDIYJlFgYGE6EJHhjHLytoy\nIKENcZ//C4rVFHJxihO7T78f6SRf7nnufteGX4/LXeMyxhgBAKwzIdsBAABjg4IHAEtR8ABgKQoe\nACxFwQOApSh4ALDUiAXf3t4uv9+vkpISNTU13be9ra1NwWBQoVBIixYt0pEjR1LbfD6fysrKFAqF\ntHjx4swmBwA4cjk9B59MJjV37lx1dHTI4/GovLxce/fuVSAQSI3p6+vTpEmTJEnnzp1TbW2tLl68\nKEl67LHH9MYbbyg/P3+MTwMA8EmOV/CxWEzFxcXy+Xxyu92qr69XW1vbkDH3yl2Sbt26pUcffXTI\ndt6jAoDscCz4RCKhoqKi1LrX61Uikbhv3P79+xUIBLR8+XJt37499XWXy6WqqiqFw2Ht2LEjg7EB\nACPJc9rocrnS2snKlSu1cuVKdXZ26tlnn9Wbb74pSTp+/LgKCwt17do1LV26VH6/X5WVlQ+fGgAw\nIseC93g8isfjqfV4PC6v1zvs+MrKSg0ODuqdd97R9OnTVVhYKEkqKChQbW2tYrHYfQW/cOFC/f3v\nf3+YcwCAz505c+akft45LOPgzp07Zvbs2ebSpUvmgw8+MMFg0Jw/f37ImIsXL5oPP/zQGGPMG2+8\nYWbPnm2MMaavr8/cuHHDGGPMrVu3zBNPPGH++Mc/3neMESKk7ac//WlG9pMJZBleLuUhy4PlUhZj\ncitPLmVJpzsdr+Dz8vLU3Nys6upqJZNJNTQ0KBAIqKWlRZLU2Nio1157Tbt375bb7dbkyZO1b98+\nSVJvb6/q6uokSYOD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345K1nuGRgY0O9//3t961vfylqGt956S7/85S/V09Ojq1ev\n6tatW9qzZ09Wsvj9fv34xz/WsmXLtHz5coVCIccLlc90wXs8HsXj8dR6PB6X1+vNYqLccufOHX3z\nm9/Ud77zHa1cuTLbcSRJU6ZM0Te+8Q2dPHkyK8c/ceKEDhw4oMcee0zPPPOMjhw5orVr12Ylyz2F\nhYWSpIKCAtXW1ioWi2Ulh9frldfrVXl5uSRp1apVOnXqVFay3HPo0CEtWrRIBQUFWctw8uRJPfHE\nE5o+fbry8vJUV1enEydOZC3PunXrdPLkSf35z3/W1KlTNXfu3GHHfqYL/uMvYg0MDKi1tVU1NTXZ\njpUTjDFqaGjQvHnz9MMf/jCrWf773//q+vXrkqTbt2/rT3/6k0KhUFaybNmyRfF4XJcuXdK+ffv0\n9a9/Xbt3785KFknq7+/XzZs3JUl9fX06fPhw1p7CmjlzpoqKivSPf/xD0t173/Pnz89Klnv27t2r\nZ555JqsZ/H6/urq6dPv2bRlj1NHRkdVbjG+//bYk6fLly/rd737nfPtqfH72O3YOHjxoHn/8cTNn\nzhyzZcuWrGapr683hYWF5otf/KLxer1m165dWcvS2dlpXC6XCQaDZuHChWbhwoXm0KFDWcly9uxZ\nEwqFTDAYNKWlpebnP/95VnJ8UjQazfpTNP/85z9NMBg0wWDQzJ8/P+vfw2fOnDHhcNiUlZWZ2tra\nrD5Fc+vWLTN9+nRz48aNrGW4p6mpycybN88sWLDArF271gwMDGQtS2VlpZk3b54JBoPmyJEjjmN5\n0QkALPWZvkUDABgeBQ8AlqLgAcBSFDwAWIqCBwBLUfAAYCkKHgAsRcEDgKX+H365oPMZsojKAAAA\nAElFTkSuQmCC\n", "text": [ - "" + "" ] } ], - "prompt_number": 5 + "prompt_number": 61 }, { "cell_type": "markdown", @@ -121,18 +117,11 @@ ], "prompt_number": 6 }, - { - "cell_type": "heading", - "level": 4, - "metadata": {}, - "source": [ - "Extracting Information from Multiple Sensor Readings" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ + "#### Extracting Information from Multiple Sensor Readings\n", "Let's put Python aside and think about the problem a bit. Suppose we were to read the following from Simon's sensor:\n", "\n", " * door\n", @@ -172,18 +161,11 @@ "We could work through the code to implement this solution, but instead let us consider a real world complication to the problem." ] }, - { - "cell_type": "heading", - "level": 4, - "metadata": {}, - "source": [ - "Noisy Sensors" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ + "####Noisy Sensors\n", "Unfortunately I have yet to come across a perfect sensor. Perhaps the sensor would not detect a door if Simon sat in front of it while scratching himself, or it might report there is a door if he is facing towards the wall, not down the hallway. So in practice when I get a report 'door' I cannot assign 1/3 as the probability for each door. I have to assign something less than 1/3 to each door, and then assign a small probability to each blank wall position. At this point it doesn't matter exactly what numbers we assign; let us say that the probably of 'door' being correct is 0.6, and the probability of being incorrect is 0.2, which is another way of saying it is about 3 times more likely to be right than wrong. How would we do this?\n", "\n", "At first this may seem like an insurmountable problem. If the sensor is noisy it casts doubt on every piece of data. How can we conclude anything if we are always unsure?\n", @@ -197,17 +179,19 @@ "cell_type": "code", "collapsed": false, "input": [ - "q = []\n", + "def measure (pos, measure, p_hit, p_miss):\n", + " q = array(pos, dtype=float)\n", + " for i in range(len(hallway)):\n", + " if hallway[i] == measure:\n", + " q[i] = pos[i] * p_hit\n", + " else:\n", + " q[i] = pos[i] * p_miss\n", + " return q\n", + "\n", "pos = array([0.2]*10)\n", - "reading = 1 # reading is 'door'\n", - "# adjust probability by the accuracy of the sensor\n", - "for i in range(len(hallway)):\n", - " if hallway[i] == reading:\n", - " q.append (pos[i] * 0.6)\n", - " else:\n", - " q.append (pos[i] * 0.2)\n", - " \n", - "pos = array(q)\n", + "reading = 1 # 1 is 'door'\n", + "pos = measure (pos, 1, .6, .2)\n", + "\n", "print pos\n", "print 'sum =', sum(pos)" ], @@ -223,7 +207,7 @@ ] } ], - "prompt_number": 17 + "prompt_number": 76 }, { "cell_type": "markdown", @@ -240,8 +224,22 @@ " s = sum(p)\n", " for i in range (len(p)):\n", " p[i] = p[i] / s\n", - "normalize(pos)\n", - "print pos\n", + " \n", + "def sense (pos, measure, p_hit, p_miss):\n", + " q = array(pos, dtype=float)\n", + " for i in range(len(hallway)):\n", + " if hallway[i] == measure:\n", + " q[i] = pos[i] * p_hit\n", + " else:\n", + " q[i] = pos[i] * p_miss\n", + " normalize(q)\n", + " return q\n", + "\n", + "\n", + "pos = array([0.2]*10)\n", + "reading = 1 # 1 is 'door'\n", + "pos = sense (pos, 1, .6, .2)\n", + "\n", "print 'sum =', sum(pos)\n", "print 'probability of door =', pos[0]\n", "print 'probability of wall =', pos[2]" @@ -253,21 +251,527 @@ "output_type": "stream", "stream": "stdout", "text": [ - "[ 0.1875 0.1875 0.0625 0.0625 0.0625 0.0625 0.0625 0.0625 0.1875\n", - " 0.0625]\n", "sum = 1.0\n", "probability of door = 0.1875\n", "probability of wall = 0.0625\n" ] } ], - "prompt_number": 21 + "prompt_number": 78 }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Normalization is done by dividing each element by the sum of all elements in the list. If this is not clear you should spend a few minutes proving it to yourself algebraically. We can see from the output that the sum is now 1.0, and that the probability of a door vs wall is still three times larger." + "Normalization is done by dividing each element by the sum of all elements in the list. If this is not clear you should spend a few minutes proving it to yourself algebraically. We can see from the output that the sum is now 1.0, and that the probability of a door vs wall is still three times larger. The result also fits our intuitiion that the probability of a door must be less than 0.333, and that the probability of a wall must be greater than 0.0. Finally, it should fit our intuition that we have not yet been given any information that would allow us to distinguish between any given door or wall position, so all door positions should have the same value, and the same should be true for wall positions. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Incorporating Movement Data\n", + "\n", + "Recall how quickly we were able to find an exact solution to our dog's position when we incorporated a series of measurements and movement updates. However, that occured in a fictional world of perfect sensors. Might we be able to find an exact solution even in the presense of noisy sensors?\n", + "\n", + "Unfortunately, the answer is no. Even if the sensor readings perfectly match an extremely complicated hallway map we could not say that we are 100% sure that the dog is in a specific position - there is, after all, the possibility that every sensor reading was wrong! Naturally, in a more typical situation most sensor readings will be correct, and we might be close to 100% sure of our answer, but never 100% sure. This may seem head-spinningly complicated, but lets just go ahead and program the math, which as we have seen is quite simple.\n", + "\n", + "First let's deal with the simple case - assume the movement sensor is perfect, and it reports that the dog has moved one space to the right. How would we alter our pos array?\n", + "\n", + "I hope after a moment's thought it is clear that we should just shift all the values one space to the right. If we previously thought there was a 50% chance of simon being at position 3, then after the move to the right we should believe that there is a 50% chance he is at position 4. So let's implement that. Recall that the hallway is circular, so we will use modulo arithmetic to perform the shift correctly" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy\n", + "def perfect_update(pos, move):\n", + " \"\"\" move the position by 'move' spaces, where positive is to the right, and negative\n", + " is to the left\n", + " \"\"\"\n", + " n = len(pos)\n", + " result = array(pos, dtype=float)\n", + " for i in range(n):\n", + " result[i] = pos[(i-move) % n]\n", + " return result\n", + " \n", + "pos = array([.4, .1, .2, .3])\n", + "print 'pos before update =', pos\n", + "pos = perfect_update(pos, 1)\n", + "print 'pos after update =', pos\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pos before update = [ 0.4 0.1 0.2 0.3]\n", + "pos after update = [ 0.3 0.4 0.1 0.2]\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can see that we correctly shifted all values one position to the right, wrapping from the end of the array back to the beginning.\n", + "\n", + "#### Adding Noise to the Update\n", + "\n", + "We want to solve real world problems, and we have already stated that all sensors have noise. Therefore the code above must be wrong. What if the sensor detected our dog moving 1 space, but he actually moved 2 spaces, or 0? Once again this may initially sound like an insummountable problem, but let's just model it in math. Since this is just an example, we will create a pretty simple noise model for the sensor - later in the book we will handle far more sophisticated errors.\n", + "\n", + "We will say that when the sensor sends a movement update, it is 80% likely to be right, and it is 10% likely to overshoot one position to the right, and 10% likely to undershoot to the left. That is, if we say the movement was 4 (meaning 4 spaces to the right), the dog is 80% likely to have moved 4 spaces to the right, 10% to have moved 3 spaces, and 10% to have moved 5 spaces.\n", + "\n", + "This is slightly harder than the math we have done so far, but it is still tractable. Each result in the array now needs to incorporate probabilities for 3 different situations. For example, consider position 9 for the case where the reported movement is 2. It should be clear that after the move we need to incorporate the probability that was at position 7 (9-2). However, there is a small chance that our dog actually moved from either 1 or 3 spaces away due to the sensor noise, so we also need to use positions 6 and 8. How much? Well, we have the probabilities, so we can just multiply and add. It would be 80% of position 7 plus 10% of position 6 and 10% of position 8! Let's try coding that:" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def update (pos, move, p_correct, p_under, p_over):\n", + " n = len(pos)\n", + " result = array(pos, dtype=float)\n", + " for i in range(n):\n", + " result[i] = \\\n", + " pos[(i-move) % n] * p_correct + \\\n", + " pos[(i-move-1) % n] * p_over + \\\n", + " pos[(i-move+1) % n] * p_under \n", + " return result\n", + "\n", + "p = array([0,0,0,1,0,0,0,0])\n", + "res = update (p, 2, .8, .1, .1)\n", + "print res" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0. 0. 0. 0. 0.1 0.8 0.1 0. ]\n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The simple test case that we ran appears to work correctly. We initially believed that the dog was in position 3 with 100% certainty; after the movement update we now give an 80% probability to the dog being in position 5, and a 10% chance to undershooting to position 4, and a 10% chance of overshooting to position 6. Let us look at a case where we have multiple beliefs:" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "p = array([0, 0, .4, .6, 0, 0, 0, 0])\n", + "res = update (p, 2, .8, .1, .1)\n", + "print res" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0. 0. 0. 0.04 0.38 0.52 0.06 0. ]\n" + ] + } + ], + "prompt_number": 57 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here the results are more complicated, but you should still be able to work it out in your head. The 0.04 is due to the possibility that the 0.4 belief undershot by 1. The 0.38 is due to the following: the 80% chance that we moved 2 positions $(.4 * .8)$ and the 10% chance that we undershot $(.6*.1)$. Overshooting plays no role here because if we overshot both .4 and .6 would be past this position. **I strongly suggest working some examples until all of this is very clear, as so much of what follows depends on understanding this step.**\n", + "\n", + "If you look at the probabilities after performing the update you probably feel dismay. In the example above we started with probabilitys of .4 and .6 in two fields; after performing the update the probabilities are not only lowered, but they are strewn out across the map." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "bar_plot (res)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAEACAYAAACuzv3DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE5BJREFUeJzt3XFs1PX9x/HXNXfJBGoHUkHuLrnZu7VXGeW0pSPG7ZjL\nCiw0oGwpOjXYkQZDDMtMjH+tmGXaLP4x6bJ0xi1x6kHiFo8tcNuKu0lw5LaUzWVlWgyN15sjAezA\nsq30y/f3B79drC3fu2vv+N4Hno/EpF/vc/d9q72n3377/R4e27ZtAQCMVeP2AACA+SHkAGA4Qg4A\nhiPkAGA4Qg4AhiPkAGC4giFPpVJqampSJBJRX1/frGvS6bRisZhWrlypeDxe7hkBAA48TteRW5al\nxsZGDQ4Oyu/3q62tTYlEQtFoNL9mfHxcd999t379618rEAjozJkzWrp06TUZHgBQ4Ig8k8koHA4r\nFArJ5/Opq6tLyWRy2ppXX31V999/vwKBgCQRcQC4xhxDnsvlFAwG89uBQEC5XG7ampGREZ07d07r\n1q1Ta2urfvazn1VmUgDArLxOD3o8noIvcOnSJQ0NDenw4cO6ePGi1q5dq89//vOKRCJlGxIAcHWO\nIff7/cpms/ntbDabP4XyP8FgUEuXLtVNN92km266SV/4whf0l7/8ZUbIw+Gw3nvvvTKODgDXv4aG\nB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MU7dSpU6qvr9f27dt15513aseOHbp48aLbY83Jvn379MADDziu\nqeh3VzVcgwnpo48+0tatW/WDH/xAixYtcnucktTU1OjPf/6zxsbG9Oabbxr1UQO/+tWvdOuttyoW\nixl5VCtJR48e1fHjx3Xo0CH98Ic/1JEjR9weqShTU1MaGhrSY489pqGhIS1cuFDPPvus22OVbHJy\nUr/85S/1ta99zXFdRUNezA1FqKxLly7p/vvv1ze+8Q1t3rzZ7XHmrK6uTl/96lf1pz/9ye1RivbW\nW2/pwIED+sxnPqNt27bpjTfe0MMPP+z2WCW57bbbJEn19fXasmWLMpmMyxMVJxAIKBAIqK2tTZK0\ndetWDQ0NuTxV6Q4dOqS77rpL9fX1jusqGvKP31A0OTmp/fv3q7Ozs5K7xMfYtq3u7m41Nzdr9+7d\nbo9TsjNnzmh8fFyS9O9//1u//e1vFYvFXJ6qeN/73veUzWZ16tQp7du3T1/60pf00ksvuT1W0S5e\nvKgLFy5IkiYmJvSb3/zGmKu3li9frmAwqHfffVfSlfPMd9xxh8tTlS6RSGjbtm0F1zneEDRfV7uh\nyCTbtm3T73//e509e1bBYFBPP/20tm/f7vZYRTl69Khefvnl/OVjkvTMM89o/fr1Lk9WnA8++ECP\nPPKILl++rMuXL+uhhx7Svffe6/ZYc2baqcbTp09ry5Ytkq6cqnjwwQf1la98xeWpird37149+OCD\nmpycVENDg3E3K05MTGhwcLCo301wQxAAGM7MX6UDAPIIOQAYjpADgOEIOQAYjpADgOEIOQAYjpAD\ngOEIOQAY7v8Av9rK1q6fmQEAAAAASUVORK5CYII=\n", + "text": [ + "" + ] + } + ], + "prompt_number": 65 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is not a coincidence, or the result of a carefully chosen example - it is always true of the update step. This is inevitable; if our sensor is noisy we will lose a bit of information on every update. Suppose we were to perform the update an infinite number of times - what would the result be? If we lose information on every step, we must eventually end up with no information at all, and our probabilities will be equally distributed across the pos array. Let's try this with say 500 iterations.\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pos = [1.0,0,0,0,0,0,0,0,0,0]\n", + "for i in range (500):\n", + " pos = update(pos, 1, .8, .1, .1)\n", + "print pos\n", + "bar_plot(pos)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF7RJREFUeJzt239M1Pfhx/HXOVjMYPVXqNQ7GpQ75QA9sLBLmzXDxYzi\nJrGVNtQ6TKUd2bIYG/9Y9lfr/qiyzqQ49gdbOhvTxvrHNmEFyUb6vZXUEmLEbglztd3RHmd13fal\nSlEPzvf3D1u+onCcFT98fPf5SD4Jn/u8P5/366PkdR8+dx+PMcYIAGCNeXMdAAAwuyh2ALAMxQ4A\nlqHYAcAyFDsAWIZiBwDLpFXsXV1dKiwsVCAQUFNT0w3bT506pfvvv1/z58/Xvn37Jl6PxWJat26d\niouLVVJSov37989ecgDAlDwzfY89mUxq1apV6u7ultfrVUVFhQ4dOqRgMDgx5uOPP9YHH3ygI0eO\naNGiRdq1a5ck6ezZszp79qxKS0s1MjKi++67T0eOHJm0LwBgds14xd7X1ye/36/8/HxlZmaqrq5O\nbW1tk8bk5OSovLxcmZmZk17Pzc1VaWmpJCk7O1vBYFBnzpyZxfgAgOvNWOzxeFx5eXkT6z6fT/F4\n/KYnGhwcVH9/v8Lh8E3vCwBI34zF7vF4bnmSkZER1dbWqrm5WdnZ2bd8PADA9DJmGuD1ehWLxSbW\nY7GYfD5f2hOMjY1p8+bN2rp1qzZt2nTD9tLSUr3zzjtpHw8AIIVCIZ08eXLKbTNesZeXl+v06dMa\nHBxUIpHQ4cOHVVNTM+XY6z+HNcaooaFBRUVF2rlz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kSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 74 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "After 500 iterations we have lost all information, even though we were 100% sure that we started in position 1. Feel free to play with the numbers to see the effect of different number of updates. For example, after 100 updates we have a small amount of information left.\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pos = [1.0,0,0,0,0,0,0,0,0,0]\n", + "for i in range (100):\n", + " pos = update(pos, 1, .8, .1, .1)\n", + "print pos\n", + "bar_plot(pos)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0.10407069 0.10329322 0.10125784 0.09874205 0.09670682 0.09592945\n", + " 0.09670682 0.09874205 0.10125784 0.10329322]\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGAZJREFUeJzt239MVffh//HXdbCYQf0ZKvVeGiwX5QJ6wUJv2qwZLmYU\nN4mttKHWYSrtyJbF2PjHsr+m+6PKGpPi2B9s6WxMG+sf24QVJBvr566klhAjdkuYq+2gvVyr67Yv\nVYp64fr+/qGlonC5Vjz3+Pb5SE7C4bzPeb/uFV8czrnHY4wxAgBYY06qAwAAZhfFDgCWodgBwDIU\nOwBYhmIHAMtQ7ABgmaSKvbOzUwUFBcrPz1djY+MN20+ePKmHH35Yc+fO1d69eye+H4lEtGbNGhUV\nFam4uFj79u2bveQAgCl5Zvocezwe14oVK9TV1SWv16vy8nIdPHhQgUBgYsynn36qjz76SIcPH9bC\nhQu1Y8cOSdKZM2d05swZlZSUaGRkRA8++KAOHz48aV8AwOya8Yy9t7dXfr9fubm5Sk9PV21trVpb\nWyeNycrKUllZmdLT0yd9Pzs7WyUlJZKkzMxMBQIBnT59ehbjAwCuN2OxR6NR5eTkTKz7fD5Fo9Gb\nnmhwcFB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pj8tbW15r777jNf//rXjc/nM7/97W8dz2CMMd3d3cbj8ZhgMGhK\nSkpMSUmJOXLkiKMZ/va3v5nS0lITDAbNypUrzS9+8QtH579eOBxO2adi/vWvf5lgMGiCwaApKipK\nyc+mMcacOHHClJWVmVWrVpnHH388ZZ+KGRkZMYsXLzbnzp1LyfzGGNPY2GgKCwtNcXGxqaurM7FY\nLCU5Hn30UVNYWGiCwaB56623bsscPKAEAJa5oy/FAABuRLEDgGUodgCwDMUOAJah2AHAMhQ7AFiG\nYgcAy1DsAGCZ/w+BJj8pTaM8KgAAAABJRU5ErkJggg==\n", + "text": [ + "" + ] + } + ], + "prompt_number": 72 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Integrating Measurements and Movement Updates\n", + "\n", + "The problem of loosing information during an update may make it seem as if our system would quickly devolve into no knowledge. However, recall that our process is not an endless series of updates, but of *measure->update->measure->update->measure->update...* The output of the measure step is fed into the update. The update step, with a degraded certainty, is then fed into the measure step. \n", + "\n", + "Let's think about this intuitively. After the first measure->update round we have degraded the knowledge we gained by the measurement by a small amount. But now we take another measurement. When we try to incorporate that new measurement into our belief, do we become more certain, less certain, or equally certain. Consider a simple case - you are sitting in your office. A co-worker asks another co-worker where you are, and they report \"in his office\". You keep sitting there while they ask and answer \"has he moved\"? \"No\" \"Where is he\" \"In his office\". Eventually you get up and move, and lets say the person didn't see you move. At that time the questions will go \"Has he moved\" \"no\" (but you have!) \"Where is he\" \"In the kitchen\". Wow! At that moment the statement that you haven't moved conflicts strongly with the next measurement that you are in the kitchen. If we were modelling these with probabilities the probability that you are in your office would lowever, and the probability that you are in the kitchen would go up a little bit. But now imagine the subsequent conversation: \"has he moved\" \"no\" \"where is he\" \"in the kitchen\". Pretty quickly the belief that you are in your office would fade away, and the belief that you are in the kitchen would increase to near certainty. The belief that you are in the office will never go to zero, nor will the belief that you are in the kitchen ever go to 1.0 because of the chances of error, but in practice your co-workers would be correct to be quite confident in their system.\n", + "\n", + "That is what intuition tells us. What does the math tell us?\n", + "\n", + "Well, we have already programmed the measure step, and we have programmed the update step. All we need to do is feed the result of one into the other, and we will have programmed our dog tracker!!! Let's see how it performs. We will input data as if the dog started at position 0 and moved right at each update. However, as in a real world application, we will start with no knowledge and assign equal probability to all positions. " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "p = array([.1]*10)\n", + "p = sense (p, 1, .6, .2)\n", + "print p\n", + "p = update (p, 1, .8, .1, .1)\n", + "print p\n", + "bar_plot(p)\n", + "\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0.1875 0.1875 0.0625 0.0625 0.0625 0.0625 0.0625 0.0625 0.1875\n", + " 0.0625]\n", + "[ 0.0875 0.175 0.175 0.075 0.0625 0.0625 0.0625 0.0625 0.075\n", + " 0.1625]\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHORJREFUeJzt3X9Mk3fiB/B3OXohJyJKUGafLmy02ha04No1muyuLuaY\n3kk25S5MDWarG9nFeCxedtlfB/tD5YyJTO4Ptuy8M7cgyf0QTmtzx+3bG5kjxICeCfOGHt1KGd7u\n9mXAUAvd5/sHrl8r8LQqPH38+H4lTXh4Pk8/7yK8eXza8jEIIQSIiEgaGekOQERE84vFTkQkGRY7\nEZFkWOxERJJhsRMRSYbFTkQkmaTFHggEYLPZYLVa0dDQMGP/5cuXsX79emRlZeHIkSMJ+w4ePIji\n4mKsWbMGO3bswM2bN+cvORERzUq12GOxGPbu3YtAIIC+vj60tLTgo48+ShiTl5eHY8eO4Wc/+1nC\n50OhEN5++2309PTg0qVLiMViOHny5Pw/AiIiSqBa7N3d3bBYLCgsLITRaERVVRXa2toSxuTn58Pl\ncsFoNCZ8PicnB0ajERMTE5iamsLExARMJtP8PwIiIkqgWu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Uenp68JOf/AQ9PT1YtGgRDh06pGmG20WjUfz5z3/G\nj370I83nvnr1Ko4ePYpQKIShoSGMj4/j3Xff1TyHzWbDz3/+c3z/+9/H5s2bUVZWtiAnIA90safy\nBqqHyeTkJLZv345du3bh2WefTWuWJUuW4Ac/+AHOnz+v6bznzp1De3s7HnvsMTz//PN47733UF1d\nrWmGbzzyyCMAgPz8fDz33HPo7u7WdH5FUaAoCtxuNwCgsrISPT09mma43dmzZ/HEE08gPz9f87nP\nnz+PDRs2IC8vD5mZmdi2bRvOnTuneQ5g+gUX58+fx9///nfk5uZi9erV8z7HA13st7+BKhqNorW1\nFRUVFemOlRZCCPh8PjgcDtTW1qYlw3/+8x+MjIwAAK5fv46//vWvKCsr0zTDgQMHEA6HMTAwgJMn\nT+Lpp5/GiRMnNM0AABMTExgbGwMAfPXVV/jLX/6i+SunCgoKYDab8fHHHwOYvr5dXFysaYbbtbS0\n4Pnnn0/L3DabDV1dXbh+/TqEEOjo6EjLZUIA+Pe//w0A+PTTT/GnP/1pYS5NzfvTsRrz+/1i1apV\noqioSBw4cEDz+auqqsQjjzwivv3tbwtFUcSvf/1rzTMIIURnZ6cwGAzC6XSK0tJSUVpaKs6ePatp\nhn/84x+irKxMOJ1OsWbNGvHLX/5S0/nvFAwG0/aqmH/961/C6XQKp9MpiouL0/K9KYQQFy5cEC6X\nS6xdu1Y899xzaXtVzPj4uMjLyxOjo6NpmV8IIRoaGoTD4RAlJSWiurpaRKPRtOR46qmnhMPhEE6n\nU7z33nsLMgffoEREJJkH+lIMERHNxGInIpIMi52ISDIsdiIiybDYiYgkw2InIpIMi52ISDIsdiIi\nyfwf+vSYxeHQUa4AAAAASUVORK5CYII=\n", + "text": [ + "" + ] + } + ], + "prompt_number": 85 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So after the first sense we have assigned a high probability to each door position, and a low probability to each wall position. The update step shifted these probabilities to the right, smearing them about a bit. Now lets look at what happens at the next sense." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "p = sense (p, 1, .6, .2)\n", + "print p\n", + "bar_plot(p)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[ 0.15671642 0.31343284 0.10447761 0.04477612 0.03731343 0.03731343\n", + " 0.03731343 0.03731343 0.13432836 0.09701493]\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGGVJREFUeJzt3X9M1Pfhx/HXOW4x06FimeIdy6lQ71A4bx4S25BdF5To\nUiLMLVRXm5UZ4tI0W5p02V+T/tGNLSbTsT+I0S6mDfJHN3GrMkfsrUzHLv6qJsYOO5nHOVfX1olg\ni1zf3z+s9xWV81S4O98+H8klfPi83/d+fax98fHD5wMOY4wRAMAakzIdAAAwvih2ALAMxQ4AlqHY\nAcAyFDsAWIZiBwDL3LXYOzs75fV6VVxcrObm5tv2d3R0yO/3KxAIaMmSJTpw4EBin8fjUVlZmQKB\ngJYuXTq+yQEAd+RIdh97PB7XggUL1NXVJZfLpfLycrW1tcnn8yXGDA4OasqUKZKkkydPqra2VmfO\nnJEkzZ07V0eOHFFeXt4EHwYA4IakZ+yRSERFRUXyeDxyOp2qr69XR0fHqDE3Sl2Srly5oscee2zU\nfp5/AoD0SlrssVhMhYWFiW23261YLHbbuN27d8vn82nlypXaunVr4vMOh0NVVVUKBoPatm3bOMYG\nAIwlJ9lOh8OR0pusXr1aq1evVnd3t5599lm99957kqSDBw+qoKBAFy9e1PLly+X1elVZWfngqQEA\nY0pa7C6XS9FoNLEdjUbldrvHHF9ZWamRkRF9+OGHmjlzpgoKCiRJ+fn5qq2tVSQSua3YFy9erHff\nffdBjgEAHjl+v1/Hjx+/806TxLVr18y8efPM2bNnzaeffmr8fr85derUqDFnzpwxn332mTHGmCNH\njph58+YZY4wZHBw0ly9f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DCBQMD4/X5TWlpqfvGLX6R1/VuFw+GM3RXzz3/+0/j9fuP3+83ChQsz9vfz+PHjJhgMmrKyMlNb\nW5uxu2KuXLliZs6caS5fvpyR9Y0xprm52ZSUlJhFixaZ9evXm+Hh4YzkqKysNCUlJcbv95sDBw5M\nyBo8oAQAlnloL8UAAO6MYgcAy1DsAGAZih0ALEOxA4BlKHYAsAzFDgCWodgBwDL/B5GCJIPVcz+Y\nAAAAAElFTkSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 86 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice the tall bar at position 1. This corresponds with the (correct) case of starting at position 0, sensing a door, shifting 1 to the right, and sensing another door. No other positions make this set of observations as likely. Now lets add an update and then sense the wall." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "p = update (p, 1, .8, .1, .1)\n", + "p = sense (p, 0, .6, .2)\n", + "bar_plot (p)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFYhJREFUeJzt3X9slHcBx/HPgz1DBFooqdDe1RyjHXel9Frtj7CF2JlC\nA2aNIJoODIurpMEsi4Y/jH+t2x/TakhE6x8Ng5lFwvhHV3RQZ7edQ1i9IDBMCMq0jOshDh21hbKV\nnl//YOvWQZ8e0D739Mv7lVzS632f+37uafnw7d09zznGGCMAgDVmZTsAAGBqUewAYBmKHQAsQ7ED\ngGUodgCwDMUOAJaZtNi7u7sViURUWlqq9vb2m27fu3evYrGYKioq9OCDD+rUqVNjt4XDYVVUVKiq\nqkq1tbVTmxwAcEuO2/vY0+m0li1bpp6eHgWDQdXU1Gjfvn2KRqNjY9544w2VlZUpLy9P3d3damtr\nU29vryRpyZIl+vOf/6z8/PzpfyQAAEmTrNgTiYRKSkoUDocVCATU3Nysrq6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i//jBUyMjI9q/\nf7+ampqyHStrjDFqaWlRWVmZvvOd72Qlw7///W8NDAxIkq5du6bf//73qqqq8jTDM888o2Qyqb6+\nPr3wwgv60pe+pOeff97TDJI0PDysoaEhSdLVq1f18ssve/7OqcWLF6u4uFh/+9vfJN14fnv58uWe\nZvi4ffv26ZFHHsnK3JFIRL29vbp27ZqMMerp6cnK04SS9M4770iSzp8/r1//+tfT89TUlL8c66GD\nBw+a+++/3yxdutQ888wzWcnQ3NxsCgsLzac//WkTCoXMnj17spLj8OHDxnEcE4vFTGVlpamsrDSH\nDh3yNMOpU6dMVVWVicViZsWKFeZHP/qRp/N/Ujwez9q7Yv7xj3+YWCxmYrGYWb58edZ+P0+ePGmq\nq6tNRUWFWb9+fdbeFXPlyhWzcOFCMzg4mJX5jTGmvb3dlJWVmfLycrNlyxYzMjKSlRyrVq0yZWVl\nJhaLmVdffXVa5uAAJQCwzIx9KgYAcGsUOwBYhmIHAMtQ7ABgGYodACxDsQOAZSh2ALAMxQ4Alvk/\nvmzTIfXHo5gAAAAASUVORK5CYII=\n", + "text": [ + "" + ] + } + ], + "prompt_number": 91 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is exciting! We have a very prominent bar at position 2 with a value of around 35%. It is over twice the value of any other bar in the plot, and is about 4% larger than our last plot, where the tallest bar was around 31%. Let's see one more sense->update cycle." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "p = update (p, 1, .8, .1, .1)\n", + "p = sense (p, 0, .6, .2)\n", + "bar_plot (p)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFXpJREFUeJzt3X9s1Hfhx/HXB3uGCLRQUqG9qznWdtyV0mu1P8IWYmcK\nDZg1gmg6MCyukgazLBr+MP61bn9MqyERrX80DGY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X4cOH\nPZ1/ZGREx48f17e//W0dP35cc+bM0Q9/+ENPM3zc8PCwfvOb3+hrX/ua53P//e9/109+8hOdO3dO\nFy5c0LVr17Rnzx7Pc0QiEX3ve9/T6tWrtWbNGlVXV8/IAuSeLfZMTp6639y8eVNf/epX9Y1vfENf\n+cpXspolLy9PX/7yl3Xs2DFP5z169Kj279+vJUuW6LHHHtPrr7+uzZs3e5rhI4WFhZKkgoICrVu3\nTolEwtP5Q6GQQqGQamtrJUkbNmzQ8ePHPc3wcQcPHtQXvvAFFRQUeD73sWPH9NBDD2nhwoXKycnR\n+vXrdfToUc9zSKMHXBw7dkx/+MMfNH/+fC1dunTa57hni/3jJ08NDw9r3759am5uznasrDHGqLW1\nVeXl5frOd76TlQz//ve/NTg4KEm6ceOGfv/736u6utrTDM8995ySyaT6+/v10ksv6Utf+pJefPFF\nTzNI0tDQkK5evSpJun79ul599VXPj5xavHixiouL9be//U3S6P7tZcuWeZrh4/bu3avHHnssK3NH\nIhH19fXpxo0bMsaot7c3K7sJJendd9+VJJ0/f16//vWvZ2bX1LS/HOuhAwcOmAcffNCUlJSY5557\nLisZWlpaTGFhofn0pz9tQqGQ2b17d1ZyHD582DiOY2KxmKmqqjJVVVXm4MGDnmY4deqUqa6uNrFY\nzCxfvtz86Ec/8nT+T4rH41k7KuYf//iHicViJhaLmWXLlmXt9/PkyZOmpqbGVFZWmnXr1mXtqJhr\n166ZhQsXmitXrmRlfmOM6ejoMOXl5aaiosJs3rzZDA8PZyXHypUrTXl5uYnFYub111+fkTk4QQkA\nLHPP7ooBANwaxQ4AlqHYAcAyFDsAWIZiBwDLUOwAYBmKHQAsQ7EDgGX+D8YOFwgwas3lAAAAAElF\nTkSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 92 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here things have degraded a bit due to the long string of wall positions in the map. We cannot be as sure where we are when there is an undifferentiated line of wall positions, so naturally our probabilities spread out a bit." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# The Effect of Bad Sensor Data\n", + "\n", + "You may be suspicious of the results above because I always passed correct sensor data into the functions. However, we are claiming that this code implements a *filter* - it should filter out bad sensor measurements. Does it do that?\n", + "\n", + "To make this easy to program and visualize I will change the layout of the hallway to mostly alternating doors and hallways:" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "hallway = [1,0,1,0,0,1,0,1,0,0]\n", + "pos = array([.1]*10)\n", + "measurements = [1,0,1,0,0]\n", + "\n", + "for m in measurements:\n", + " pos = sense (pos, m, .6, .2)\n", + " pos = update (pos, 1, .8, .1, .1)\n", + "bar_plot(pos)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFT5JREFUeJzt3X9s1Hfhx/HXB3uGyI9CSYX2ruZY23FXSq/VKxe2EDtT\naMCskYqmA8PiKmlmzKLZH8a/BvtjWg2JaP2jYTCzSFj/0RUFKuJ2DsuaCwLDpEFR23E9xOFGLVC2\n0vP9/QPWLxV6XKH93Ic3z0dyST/9vD/3fh288+qnn7tP6hhjjAAA1piV6wAAgOlFsQOAZSh2ALAM\nxQ4AlqHYAcAyFDsAWOauxd7d3a1QKKTy8nK1tbXdtn/v3r2KRCKqqqrS448/rtOnT4/vCwaDqqqq\nUk1NjVauXDm9yQEAd+Rk+hx7Op3WsmXLdOTIEfn9ftXW1mrfvn0Kh8PjY95++21VVFQoPz9f3d3d\n2rZtm3p7eyVJS5cu1Z/+9CcVFBTM/CsBAEi6yxl7IpFQWVmZgsGgfD6fmpub1dXVNWHMqlWrlJ+f\nL0mKxWIaHBycsJ/7nwDAXRmLPZVKqaSkZHw7EAgolUpNOn737t1av379+LbjOKqvr1c0GtWuXbum\nIS4A4G7yMu10HCfrJ3rzzTe1Z88e9fT0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Vvv27dNTTz2Vk7lDoZB6\ne3t17do1GWN05MiRnFwmlKT33ntPknTu3Dn96le/mplLU9P+dqyLDh48aB599FFTWlpqXnrppZxk\naG5uNkVFReaTn/ykCQQCZs+ePTnJcfToUeM4jolEIqa6utpUV1ebQ4cOuZrh9OnTpqamxkQiEbNi\nxQrzwx/+0NX5/1c8Hs/Zp2L+8Y9/mEgkYiKRiFm+fHnO1uepU6dMNBo1VVVVZsOGDTn7VMyVK1fM\nokWLzPDwcE7mN8aYtrY2U1FRYSorK82WLVvM6OhoTnKsXr3aVFRUmEgkYt54440ZmYMblADAMg/s\npRgAwJ1R7ABgGYodACxDsQOAZSh2ALAMxQ4AlqHYAcAyFDsAWOb/AM8XDghkBPSFAAAAAElFTkSu\nQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 97 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "At this point we have correctly identified the likely cases, we either started at position 0 or 5, because we saw the following sequence of doors and walls 1,0,1,0,0. But now lets inject a bad measurement, and see what happens:\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "pos = sense (pos, m, .6, .2)\n", + "pos = update (pos, 1, .8, .1, .1)\n", + "bar_plot(pos)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG3tJREFUeJzt3X9sE+fhP/C3M3tCS5oEokCKz1Xa2BA7AcfUrkWlbmZC\nS5ONiJa0SoEFQWDRKsRA/DH1r8H+KGQMqYHsj2zqqNCqNNJ+kJSYaMv6dRuVWhlK6CZljLRzWts0\nrNs+IYQAjt3n+weQEZJcDITLw8P7JZ2Uyz13z9vm9M7lYmOTEEKAiIiUkTHfAYiIaG6x2ImIFMNi\nJyJSDIudiEgxLHYiIsWw2ImIFDNrsXd2dqK4uBgOhwMNDQ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B1dTV6e3sNzXC7U6dO4emnn0Z+fr7hc585cwbPPvss8vLyYDab8eKLL+L06dOG\n5wBuvODizJkzeP/995Gbm4vly5fP+RwPdbHf/gaqRCKB1tZWVFVVzXeseSGEQF1dHVwuF3bv3j0v\nGf79739jeHgYAHD16lX86U9/gsfjMTTD66+/jmg0ikgkgnfeeQff/va3cfz4cUMzAMDY2BguX74M\nALhy5Qr++Mc/Gv7KqYKCAthsNpw/fx7AjfvbJSUlhma4XUtLC1555ZV5mbu4uBjhcBhXr16FEAJd\nXV3zcpsQAP71r38BAD7//HP84Q9/eDC3pub8z7EGCwaDYtmyZaKoqEi8/vrrhs9fU1MjHn/8cfH1\nr39daJomfv3rXxueQQghuru7hclkEm63W5SVlYmysjJx6tQpQzP89a9/FR6PR7jdbrFixQrxs5/9\nzND57xQKhebtVTH//Oc/hdvtFm63W5SUlMzLuSmEEGfPnhVer1esXLlSvPDCC/P2qpjR0VGRl5cn\nRkZG5mV+IYRoaGgQLpdLlJaWitraWpFIJOYlx3PPPSdcLpdwu93ivffeeyBz8A1KRESKeahvxRAR\n0VQsdiIixbDYiYgUw2InIlIMi52ISDEsdiIixbDYiYgUw2InIlLM/wdGFYkCmoLrlQAAAABJRU5E\nrkJggg==\n", + "text": [ + "" + ] + } + ], + "prompt_number": 98 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "That one bad measurment appears to have significantly eroded our knowledge. However, note that our highest probabilities are still at 0 and 5, which is correct. Now let's continue with a series of correct measurements" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "measurements = [0,1,0,1,0,0]\n", + "\n", + "for m in measurements:\n", + " pos = sense (pos, m, .6, .2)\n", + " pos = update (pos, 1, .8, .1, .1)\n", + "bar_plot(pos)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n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eXnms5/9rPH7/Wbr1q0ZyXHgwAHj8XhMOBw2paWl\nprS01Ozbty+tGY4fP24ikYgJh8Nm0aJF5ic/+Ulaj/9p0Wg0Y++K+cc//mHC4bAJh8Nm4cKFGVuf\nx44dM2VlZaakpMTU19dn7F0xFy9eNDNnzjTnz5/PyPGNMaa5udkUFRWZ4uJis2bNGjM4OJiRHJWV\nlaaoqMiEw2Gzf//+u3IMLlACAMvcs0/FAABujWIHAMtQ7ABgGYodACxDsQOAZSh2ALAMxQ4AlqHY\nAcAy/wdXqpA50S9AggAAAABJRU5ErkJggg==\n", + "text": [ + "" + ] + } + ], + "prompt_number": 100 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see we quickly filtered out the bad sensor reading and converged on the most likely positions for our dog." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Summary\n", + "\n", + "The code is very small, but the result is huge! We will go into the math more later, but we have implemented a form of a Bayesian filter. It is commonly called a Histogram filter. The Kalman filter is also a Bayesian filter, and uses this same logic to produce it's results. The math is a bit more complicated, but not by much. For now, we will just explain that Bayesian statistics compute the liklihood of the present based on the past. If we know there are two doors in a row, and the sensor reported two doors in a row, it is likely that we are positioned near those doors. Bayesian statistics just formalizes that example, and Bayesian filters formalize filtering data based on that math by implementing the sense->update->sense->update process. \n", + "\n", + "We have learned how to start with no information and derive information from noisy sensors. Even though our sensors are very noisey (most sensors are more then 80% accurate, for example) we quickly converge on the most likely position for our dog. We have learned how the update step always degrades our knowledge, but the addition of another measurement, even when it might have noise in it, improves our knowlege, allowing us to converge on the most likely result.\n", + "\n", + "If you followed the math carefully you will realize that all of this math is exact. The bar charts that we are displaying are not an *estimate* or *guess* - they are mathematically exact results that exactly represent our knowledge. The knowledge is probabilistic, to be sure, but it is exact, and correct.\n", + "\n", + "However, we are a long way from tracking an airplane or a car. This code only handles the 1 dimensional case, whereas cars and planes operate in 2 or 3 dimensions. Also, our position vector is *multimodal*. It expresses multiple beliefs at once. Imagine if your GPS told you \"it's 20% likely that you are here, but 10% likely that you are on this other road, and 5% likely that you are at one of 14 other locations. That would not be very useful information. Also, the data is discrete. We split an area into 10 (or whatever) different locations, whereas in most real world applications we want to work with continuous data. We want to be able to represent moving 1 km, 1 meter, 1 mm, or any arbitrary amount, such as 2.347 cm. \n", + "\n", + "Finally, the bar charts may strike you as being a bit less certain than we would want. A 25% certaintly may not give you a lot of confidence in the anwser. Of course, what is important here is the ratio of this probability to the other probabilities in your vector. If the next largest bar is 23% then we are not very knowledgable about our position, whereas if the next largest is 3% we are in fact quite certain. But this is not clear or intuitive. However, there is an extremely important insight that Kalman filters implement that will signficantly improve our accuracy from the same data.\n", + "\n", + "**If you can understand this chapter you will be able to understand and implement Kalman filters** I cannot stress this enough. If anything is murky, go back and reread this chapter and play with the code. the rest of this book will build on the algorithms that we use here. If you don't intuitively understand why this histogram filter works, and can at least work through the math, you will have little success with the rest of the material. However, if you grasp the fundamental insight - multiplying probabilities when we measure, and shifting probabilities when we update leads to a converging solution - then you understand everything important you need to grasp the Kalman filter. " ] }, { @@ -278,6 +782,22 @@ "Gaussian Probabilities" ] }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + }, { "cell_type": "markdown", "metadata": {},