[SciPy-user] segfault in scipy.optimize.leastsq

basvandijk at home.nl basvandijk at home.nl
Thu Aug 3 08:12:09 CDT 2006


Hello,

When running the following example from http://www.tau.ac.il/~kineret/amit/scipy_tutorial I get an segmentationfault in leastsq:

--------------------------
from scipy import *
from numpy import *

x = arange(0,6e-2,6e-2/30)
A,k,theta = 10, 1.0/3e-2, pi/6s
y_true = A*sin(2*pi*k*x+theta)
y_meas = y_true + 2*randn(len(x))

def residuals(p, y, x):
    A,k,theta = p
    err = y-A*sin(2*pi*k*x+theta)
    return err

def peval(x, p):
    return p[0]*sin(2*pi*p[1]*x+p[2])

p0 = [8, 1/2.3e-2, pi/3]
print array(p0)

from scipy.optimize import leastsq
plsq = leastsq(residuals, p0, args=(y_meas, x))
print plsq[0]

print array([A, k, theta])
--------------------------

Note that C:\Python24\Lib\site-packages\scipy\optimize\tests\test_optimize.py also gives an error.

I'm running Python 2.4.3, Scipy 0.5.0 and numpy 1.0b1.

What can be the problem?

Greetings,

Bas van Dijk


More information about the SciPy-user mailing list