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:
26
code/DogSensor.py
Normal file
26
code/DogSensor.py
Normal 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
|
||||
Reference in New Issue
Block a user