1

I'm trying to use np.polyfit and I keep getting the error:

TypeError: polyfit() got an unexpected keyword argument 'w'

The documentation on that function clearly mentions this argument so I'm not sure whats going on. I'm using SciPy 0.12.0 and NumPy 1.6.1.

Here's a MWE that returns that error:

import numpy as np

x = np.array([0.0, 1.0, 2.0, 3.0,  4.0,  5.0])
y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
weight = np.array([0.2, 0.8, 0.4, 0.6, 0.1, 0.3])

poli = np.polyfit(x, y, 3, w=weight)
Gabriel
  • 40,504
  • 73
  • 230
  • 404

1 Answers1

3

This is the reference for your numpy version, the argument 'w' was only introduced in a later version.

Martin Böschen
  • 1,707
  • 15
  • 22
  • Thanks, off to upgrade numpy then. – Gabriel Nov 07 '13 at 15:00
  • 1
    @Gabriel After you upgrade, you may consider switching to use [`from numpy.polynomial import polynomial as poly`](http://docs.scipy.org/doc/numpy/reference/routines.polynomials.polynomial.html) and [`poly.polyfit(x, y, 3, ...)`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.polynomial.polyfit.html) – askewchan Nov 07 '13 at 15:22
  • @askewchan I'll do that as soon as I am able to upgrade. Apparently it is not that simple :( http://stackoverflow.com/questions/19839488/cant-upgrade-numpy-on-ubuntu-12-04 – Gabriel Nov 07 '13 at 15:27