title: NumPy PolyFit and PolyVal in Multiple Dimensions?
body: <p>Assume an n-dimensional array of observations that are reshaped to be a 2d-array with each row being one observation set.  Using this reshape approach, <code>np.polyfit</code> can compute 2nd order fit coefficients for the entire ndarray (vectorized):</p>
  
  <pre><code>fit = np.polynomial.polynomialpolyfit(X, Y, 2)
  </code></pre>
  
  <p>where Y is shape (304000, 21) and X is a vector.  This results in a (304000,3) array of coefficients, fit.  </p>
  
  <p>Using an iterator it is possible to call <code>np.polyval(fit, X)</code> for each row.  This is inefficient when a vectorized approach may exist.  Could the <code>fit</code> result be applied to the entire observation array without iterating?  If so, how?</p>
  
  <p>This is along the lines of <a href="https://stackoverflow.com/questions/19282429/regression-along-a-dimension-in-a-numpy-array">this SO</a> question.</p>