title: How to fix "polyfit maybe poorly conditioned" in numpy?
body: <p>I am trying to do a polyfit on a set of data using numpy package.</p>
  <p>The following is the code, it can run successfully. The fitted line seems to fit the data when the order reaches around 20(very high). However, at the end, it says &quot;Polyfit may be poorly conditioned&quot;.</p>
  <p>If I am not wrong, it is that when the degree gets higher, the fitting will be sensitive to the data, i.e. easily influenced by the data? How can I fix this?</p>
  <pre><code>def gen_data_9(length=5000):
  x = 2.0 * (np.random.rand(length) - 0.5) * np.pi * 2.0
  f = lambda x: np.exp(-x**2) * (-x) * 5 + x / 3
  y = f(x) + np.random.randn(len(x)) * 0.5
  return x, y, f
  
  fig,ax = plt.subplots(3,3,figsize = (16,16))
  
  for n in range(3):
      for k in range(3):
      
          order = 20*n+10*k+1
          z = np.polyfit(x,y,order)
          p = np.poly1d(z)
  
          ax[n,k].scatter(x,y,label = &quot;Real data&quot;,s=1)
          ax[n,k].scatter(x,p(x),label = &quot;Polynomial with order={}&quot;.format(order),
                      color='C1',s=1)
      ax[n,k].legend()
  
  fig.show()
  </code></pre>