[Tutor] leastsquares.py
Alan Gauld
alan.gauld at freenet.co.uk
Wed Dec 29 23:31:18 CET 2004
> I am trying to use a least squares method (the one written by Konrad
Hinsen),
> but I do not want the method to be able to generate negative values.
Is there
> a way to stop least squares programs from doing so?
def _leastSquare():
# do the thing that might generate negatives
def leastSquare():
firstTry = _leastSquare()
if firstTry < 0:
return leastSquare() # try again
else:
return firstTry
Primitive but it works. If you want more a efficient/elegant solution
show us what you have...
Alan G.
More information about the Tutor
mailing list