Fixed path issues, improved gaussian discussion.

Chapter was not adding ../code to the search path. Multivarite discusion about the ellipses
was a bit unclear about the relationship of the standard deviation.
This commit is contained in:
Roger Labbe
2014-09-05 08:10:47 -07:00
parent c8e2f6831b
commit 1f806719f3
2 changed files with 51 additions and 40 deletions

26
code/DogSensor.py Normal file
View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
Created on Sun May 11 13:21:39 2014
@author: rlabbe
"""
from __future__ import print_function, division
import numpy.random as random
import math
class DogSensor(object):
def __init__(self, x0=0, velocity=1, noise=0.0):
""" x0 - initial position
velocity - (+=right, -=left)
noise - scaling factor for noise, 0== no noise
"""
self.x = x0
self.velocity = velocity
self.noise = math.sqrt(noise)
def sense(self):
self.x = self.x + self.velocity
return self.x + random.randn() * self.noise