[Numpy-discussion] Using normal()

Keith Goodman kwgoodman at gmail.com
Thu Apr 24 13:16:58 EDT 2008


On Thu, Apr 24, 2008 at 10:01 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>    In the application's function I now have:
>
>    from numpy import *
>
>    x = nx.arange(0, 100, 0.1)
>    y = nx.normal(center,width)  # passed to the function when called
>
>  and I then pass x,y to PyX for plotting. But python responds with:
>
>    y = nx.normal(center,width)
>  AttributeError: 'module' object has no attribute 'normal'

It's random.normal(loc, scale). But that will give you random x values
drawn from the normal distribution, not y values at your x. So you'll
have to code your own normal, which will probably look something like

norm = 1 / (scale * sqrt(2 * pi))
y = norm * exp(-power((x - loc), 2) / (2 * scale**2))



More information about the NumPy-Discussion mailing list