[Numpy-discussion] Using normal()
Keith Goodman
kwgoodman@gmail....
Thu Apr 24 12:16:58 CDT 2008
On Thu, Apr 24, 2008 at 10:01 AM, Rich Shepard <rshepard@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