Chicrala
Chicrala

Reputation: 1054

Is the numpy.linalg.lstsq rcond parameter not working according to the description?

I am trying to use the least squares solution from numpy (Description). According to the website to use the new default for the 'rcond' parameter: ''To silence the warning and use the new default, use rcond=None, to keep using the old behavior, use rcond=-1.''

With the rcond parameter set to None:

vector = np.linalg.lstsq(GA, FA, rcond = None)

It returns me an error:

TypeError: must be real number, not NoneType

Which does not happen when the parameter is taken away or set to -1.

I did some check and according to this post and one of the answers had an update stating that there were some recent changes on this method.

Then I would like to ask if someone else is having the same problem or if there is something as a typo on my line (Or something else I haven't thought about).

Kind Regards, Thanks for your time.

Upvotes: 3

Views: 4241

Answers (2)

Bill Hatch
Bill Hatch

Reputation: 1

 x = np.array([0, 1, 2, 3])
 y = np.array([-1, 0.2, 0.9, 2.1])
 A = np.vstack([x, np.ones(len(x))]).T
 print(A)
 m, c = np.linalg.lstsq(A, y, rcond=1.e-10)[0]
 print (m,c)
# rcond must be a float. None as in the documentation 
# gives the "TypeError: a float is required"

Upvotes: 0

Charles Harris
Charles Harris

Reputation: 984

You need NumPy >= 1.14. What version are you using?

Upvotes: 2

Related Questions