title: How to fit a polynomial with some of the coefficients constrained?
body: <p>Using NumPy's <code>polyfit</code> (or something similar) is there an easy way to get a solution where one or more of the coefficients are constrained to a specific value?</p>
  
  <p>For example, we could find the ordinary polynomial fitting using:</p>
  
  <pre><code>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])
  z = np.polyfit(x, y, 3)
  </code></pre>
  
  <p>yielding</p>
  
  <pre><code>array([ 0.08703704, -0.81349206,  1.69312169, -0.03968254])
  </code></pre>
  
  <p>But what if I wanted the best fit polynomial where the third coefficient (in the above case <code>z[2]</code>) was required to be 1? Or will I need to write the fitting from scratch?</p>