Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Robert Kern wrote: > No, it's not! scale is the standard deviation of the Normal distribution, > not half the FWHM! OK. Thanks for clearing up my mis-understanding. Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Ser

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Robert Kern
On Thu, Apr 24, 2008 at 1:39 PM, Rich Shepard <[EMAIL PROTECTED]> wrote: > On Thu, 24 Apr 2008, Joris De Ridder wrote: > > > Scale is half the width between the inflection points, mind the factor of > > 2. > > Joris, > >So, half of the full width at half the maximum height. Thank you. No, i

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Zachary Pincus wrote: > I assume you 'from numpy import *'? This is why it works -- because that > import causes the python built-in exp() to be replaced (in the current > namespace) by numpy.exp(). The equivalent (I think): import numpy as nx. Rich -- Richard B. Shepar

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Anne Archibald
On 24/04/2008, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Thu, Apr 24, 2008 at 10:01 AM, Rich Shepard <[EMAIL PROTECTED]> wrote: > >In the application's function I now have: > > > >from numpy import * > > > >x = nx.arange(0, 100, 0.1) > >y = nx.normal(center,width) # passe

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Zachary Pincus wrote: > Python's built in pow() and exp() functions can't handle numpy arrays, and > thus try (and fail) to convert arrays to scalar values. You want to use > numpy.exp and numpy.power (or just the ** operator), to do these > operations to numpy arrays elementw

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Joris De Ridder wrote: > Scale is half the width between the inflection points, mind the factor of > 2. Joris, So, half of the full width at half the maximum height. Thank you. Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Joris De Ridder
On 24 Apr 2008, at 19:26, Rich Shepard wrote: >> norm = 1 / (scale * sqrt(2 * pi)) >> y = norm * exp(-power((x - loc), 2) / (2 * scale**2)) > > Can do. So, scale would equate to width and loc to center, yes? Scale is half the width between the inflection points, mind the factor of 2. J. D

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Zachary Pincus
> It works for me: > >>> x = arange(0,10) >>> scale=1 >>> loc=1 >>> norm = 1 / (scale * sqrt(2 * pi)) >>> y = norm * exp(-power((x - loc), 2) / (2 * scale**2)) >>> y > > array([ 1.46762663e-01, 3.98942280e-01, 1.46762663e-01, > 5.39909665e-02, 2.68805194e-03, 1.33830226e-04, >

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Keith Goodman
On Thu, Apr 24, 2008 at 10:51 AM, Rich Shepard <[EMAIL PROTECTED]> wrote: > On Thu, 24 Apr 2008, Keith Goodman wrote: > > > norm = 1 / (scale * sqrt(2 * pi)) > > y = norm * exp(-power((x - loc), 2) / (2 * scale**2)) > >Hmm-m-m. I don't understand the source of the error: > >y = norm * exp

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Zachary Pincus
>> norm = 1 / (scale * sqrt(2 * pi)) >> y = norm * exp(-power((x - loc), 2) / (2 * scale**2)) > > Hmm-m-m. I don't understand the source of the error: > > y = norm * exp(-pow((x - loc), 2) / (2 * scale**2)) > TypeError: only length-1 arrays can be converted to Python scalars Python's built in

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Keith Goodman wrote: > norm = 1 / (scale * sqrt(2 * pi)) > y = norm * exp(-power((x - loc), 2) / (2 * scale**2)) Hmm-m-m. I don't understand the source of the error: y = norm * exp(-pow((x - loc), 2) / (2 * scale**2)) TypeError: only length-1 arrays can be converted to

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Zachary Pincus wrote: > The only remaining mystery is how 'loc' and 'scale' -- the parameters of > numpy.random.normal -- map to 'mean' and 'standard deviation', which is > how a normal distribution is usually parameterized. Fortunately, the > documentation reveals this: > > >

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Zachary Pincus
> The syntax is normal(loc=0.0, scale=1.0, size=None), but I've not > seen > what those represent, nor how to properly invoke this function. A > clue will > be much appreciated. > > I want to call normal() passing at least the width of the curve(at > the end > points where y=0.0), and the

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
On Thu, 24 Apr 2008, Keith Goodman wrote: > 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 Keith, I overlooked that, thanks.

Re: [Numpy-discussion] Using normal()

2008-04-24 Thread Keith Goodman
On Thu, Apr 24, 2008 at 10:01 AM, Rich Shepard <[EMAIL PROTECTED]> 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.

[Numpy-discussion] Using normal()

2008-04-24 Thread Rich Shepard
Rereading "Guide to NumPy" once again, I saw what I had missed all the previous times: the normal() distribution function (Chapter 10, page 173). I have several questions on using it in my application. The syntax is normal(loc=0.0, scale=1.0, size=None), but I've not seen what those represen