Kalman-and-Bayesian-Filters.../dog_track_1d.py
Roger Labbe 0b149352ed Interim check in.
dog_track_1d is just a file to test code before putting it into the
Kalman filter chapter.
2014-04-30 12:52:15 -05:00

36 lines
651 B
Python

# -*- coding: utf-8 -*-
"""
Created on Wed Apr 30 10:35:19 2014
@author: rlabbe
"""
import numpy.random as random
class dog_sensor(object):
def __init__(self, x0 = 0, motion=1, noise=0.0):
self.x = x0
self.motion = motion
self.noise = math.sqrt(noise)
def sense(self):
self.x = self.x + self.motion
self.x += random.randn() * self.noise
return self.x
def measure_dog ():
if not hasattr(measure_dog, "x"):
measure_dog.x = 0
measure_dog.motion = 1
if __name__ == '__main__':
dog = dog_sensor(noise = 1)
for i in range(10):
print (dog.sense())