greenteawarrior/mobile-robotics — pull request #30 by cypressf (2014-10-11 18:17:57+00:00)
Title: normal function is 10x faster

I tested my normal function by comparing its output to that of norm.pdf

>>> def normal(x, sigma, mu=0.0):
... """
... See equation at http://en.wikipedia.org/wiki/Normal_distribution
... """
... power = -(x-mu)**2 / (2.0*sigma**2.0)
... multiple = (1.0 / (sigma * math.sqrt(2.0 * math.pi)))
... return multiple * math.e**power
...
>>> from scipy.stats import norm
>>> import math
>>> mu = 0.0
>>> sigma = 0.05
>>> x = 0
>>> norm.pdf(loc=mu, scale=sigma, x=x)
7.9788456080286538
>>> normal(x,sigma,mu=mu)
7.978845608028654