leastSquaresFit
Alex Tournier
alex.tournier at iwr.uni-heidelberg.de
Tue Jul 9 09:08:29 EDT 2002
Here's a question/problem with the leastSquaresFit function which is
part of Numeric module.Hope you can help,
I try the example given in the documentation and here is what i get:
>>> from Scientific.Functions.LeastSquares import leastSquaresFit
>>> import Numeric
>>>
>>> # The mathematical model.
... def exponential(parameters, x):
... a = parameters[0]
... b = parameters[1]
... return a*Numeric.exp(-b/x)
...
>>> # The data to be fitted to.
... data = [(100, 4.999e-8),
... (200, 5.307e+2),
... (300, 1.289e+6),
... (400, 6.559e+7)]
>>>
>>> fit = leastSquaresFit(exponential, (1e13, 4700), data)
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/lib/python1.5/site-packages/Scientific/Functions/LeastSquares.py",
line 66, in leastSquaresFit
-0.5*Numeric.array(chi_sq[1]))
File "/usr/lib/python1.5/site-packages/Numeric/LinearAlgebra.py",
line 61, in solve_linear_equations
_assertRank2(a, b)
File "/usr/lib/python1.5/site-packages/Numeric/LinearAlgebra.py",
line 47, in _assertRank2
raise LinAlgError, 'Array must be two-dimensional'
LinearAlgebraError: Array must be two-dimensional
Anybody have an idea were this might come from, I use the Numeric
module all the time without any prob, but I can't get this
leastSquaresFit function to work!!
Cheers,
Alex
More information about the Python-list
mailing list