On 24/11/2007, Rich Shepard <[EMAIL PROTECTED]> wrote:
> On Fri, 23 Nov 2007, Angus McMorland wrote:
>
> > For parsimony, I think you're probably best off just using the Gaussian
> > equation:
> >
> > def fwhm2k(fwhm):
> >    '''converts fwhm value to k (see above)'''
> >    return fwhm/(2 * n.sqrt( n.log( 2 ) ) )
> >
> > def gauss1d(r, fwhm, c):
> >    '''returns the 1d gaussian given by fwhm (full-width at half-max),
> >    and c (centre) at positions given by r
> >    '''
> >    return exp( -(r-c)**2 / fwhm2k( fwhm )**2 )
> >
> > (released to public domain)
>
> Angus,
>
>    I'm trying to find the context for the above so I know what to feed fwhm2k
> as the fwhm value.

fwhm is the full-width at half the maximum height, i.e. it's the
difference between the two values of x when:

|r - c| = 0.5

The fwhm is a shape parameter (like std dev) - it determines the width
of the curve. The combination of width and the range of values you
plot (r) determine how close the function gets to zero, and how much
of it is plotted. As Jeff said, it'll never actually reach zero, so
you have to decide how close is close enough.

You don't need to call fwhm2k yourself;  it's called by the gauss1d
function. I just do it that way because the equation uses k, but I'm
always interested in fwhm.

>    It's been decades since I needed to work with continuous distributions and
> my insights and skills have rusted.

Perhaps the easiest thing is to shove it into some quick code and play
around with the values so you see how it works:

import pylab as p, numpy as n
x = n.arange(100) - 50.
fwhm = 25
centre = 0
y = gauss1d(x, fwhm, centre)
p.plot(x,y)

If you have other questions, you'll need to be a bit more specific so
we can address them directly.

Angus.
-- 
AJC McMorland, PhD Student
Physiology, University of Auckland

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to