Ooops, a small glitch went in my 'vectorized' version. This has been tested: from scipy import * xdata = array([5.357, 5.457, 5.797, 5.936, 6.161, 6.697, 6.731, 6.775, 8.442, 9.769, 9.861]) ydata = array([0.376, 0.489, 0.874, 1.049, 1.327, 2.054, 2.077, 2.138, 4.744, 7.068, 7.104]) matrix=transpose(array([[1]*11, xdata, xdata*xdata])) # y = 1 + x + x*x coeffs = linalg.basic.lstsq(matrix, ydata)[0] print "scipy.linalg.basic.lstsq curve fitting example" print "fitting data to quadratic equation y = a + bx + cx^2" ycalc = coeffs[0] + coeffs[1] * xdata + coeffs[2] * xdata * xdata error = ycalc - ydata print "yields: x data y data calc value error" for i in range(len(xdata)): print " % .3f % .3f % .3f % .3f" % (xdata[i], ydata[i], ycalc[i], error[i]) print -- Francesc Alted