On 25/11/2007, Rich Shepard <[EMAIL PROTECTED]> wrote:
> On Sun, 25 Nov 2007, Angus McMorland wrote:
>
> > I'm not completely sure, but I suspect that this is an implementation bug,
> > rather than a version bug, particularly because the line in question isn't
> > involving matplotlib at all. If you post the relevant code
> > (normal-curve.py, by the looks of things), it might be easy to spot the
> > problem.
>
> Angus,
>
> I've seen the same error trying to plot other curves in the past couple of
> days, but not those using the Boltzmann distribution. Here's the file:
>
> import matplotlib.numerix as nx
> import pylab as p
> from math import *
>
> center = 50.0
> fwhm = 50.0
>
> def fwhm2k(fwhm):
> '''converts fwhm value to k (see above)'''
> return fwhm/(2 * nx.sqrt(nx.log(2)))
>
> def gauss1d(r, fwhm, center):
> '''returns the 1d gaussian given by fwhm (full-width at half-max),
> and c (centre) at positions given by r
> '''
> return exp(-(r-center)**2 / fwhm2k(fwhm)**2)
>
> x = nx.arange(0, 100, 0.1)
> G = gauss1d(x, fwhm, center)
> p.plot(x, G, color='red', lw=2)
> p.axis([0, 100, 0.0, 1.0])
> p.xlabel('Universe of Discourse')
> p.ylabel('Membership Grade')
> p.show()
>
As I suspected, this is a parameter issue- in this case caused by your
use of the ath module routines which require scalar input, rather than
numpy's (or matplotlib's numerix's) array-friendly versions. If you
change exp -> nx.exp in your definition of gauss1d, all works okay.
A.
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users