title: Python fmin too slow
body: <p>i have a 3x2000 numpy array in x_data and a 1x2000 numpy array in y_data which i pass to this function regress to give me a regression line.  it works fine.  the problem is that i am trying to do some backtesting and to test 1000 situations i have to regress 1000 times and it will take me about 5 minutes to run this.  </p>
  
  <p>i tried standardizing the variables it didn't seem to make it faster.</p>
  
  <p>i also briefly tried fmin_powell and fmin_bfgs which seemed to break it.  </p>
  
  <p>any ideas? thanks!</p>
  
  <pre><code>def regress(x_data, y_data, fg_spread, fg_line):
  
      theta = np.matrix(np.ones((1,x_data.shape[0]))*.11)
      hyp = lambda theta, x: 1 / (1 + np.exp(-(theta*x)))
      cost_hyp = lambda theta, x, y: ((np.multiply(-y,np.log10(hyp(theta,x)))) - \
                              (np.multiply((1-y),(np.log10(1-hyp(theta, x)))))).sum()
  
      theta = scipy.optimize.fmin(cost_hyp, theta, args=(x_data,y_data), xtol=.00001, disp=0)
  
      return hyp(np.matrix(theta),np.matrix([1,fg_spread, fg_line]).reshape(3,1))
  </code></pre>