title: Estimating parameter values using optimize.curve.fit
body: <p>I am attempting to estimate the parameters of the non-linear equation: </p>
  
  <pre><code>y(x1, x2) = x1 / A + Bx1 + Cx2 
  </code></pre>
  
  <p>using the method outlined in the answer to <a href="https://stackoverflow.com/questions/3938042/fitting-exponential-decay-with-no-initial-guessing">this question</a>, but can find no documentation on how to pass multiple independent variables to the curve_fit function appropriately.</p>
  
  <p>Specifically, I am attempting to estimate plant biomass (y) on the basis of the density of the plant (x1), and the density of a competitor (x2).  I have three exponential equations (of the form y = a[1-exp(-b*x1)]) for the the relationship between plant density and plant biomass, with different parameter values for three competitor densities:</p>
  
  <pre><code>For x2 == 146: y = 1697 * [1 - exp(-0.010 * x1)]
  
  For x2 == 112: y = 1994 * [1 - exp(-0.023 * x1)]
  
  For x2 == 127: y = 1022 * [1 - exp(-0.008 * x1)]
  </code></pre>
  
  <p>I would therefore like to write code along the lines of:</p>
  
  <pre><code>def model_func(self, x_vals, A, B, C):
      return x_vals[0] / (A + B * x_vals[0] + C * x_vals[1])
  
  def fit_nonlinear(self, d, y):
      opt_parms, parm_cov = sp.optimize.curve_fit(self.model_func, [x1, x2], y, p0 = (0.2, 0.004, 0.007), maxfev=10000)
      A, B, C = opt_parms
      return A, B, C
  </code></pre>
  
  <p>However I have not found any documentation on how to format the argument y (passed to <code>fit_nonlinear</code>) to capture to two-dimensional nature of the x_vals (<a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html" rel="nofollow noreferrer">the documentation for curve_fit</a> states y should be an N-length sequence).  Is what I am attempting possible with <code>curve_fit</code>?</p>