title: Function minimization with error in Python
body: <p>I have a function of the form: (y1,y2,y3)=x*(a1,a2,a3)+(b1,b2,b3), where x,y1,y2,y3 are measured values and a1,a2,a3,b1,b2,b3 are parameters I want to fit for. I also have some measurement errors associated with x,y1,y2,y3. I would like to fit this function for a1,a2,a3,b1,b2,b3, and obtain an error on the values of each of these parameters, while taking into account the errors on x,y1,y2,y3. How can I do this? I looked into scipy and lmfit, but I didn't really find something that allows me to both pass the errors on the measured points and return the errors on the fitted parameters. Here is some code I have for the data I need to fit:</p>
  <pre><code>import numpy as np
  x = np.array([1,2,3,4,5])
  err_x = np.array([0.1,0.1,0.2,0.2,0.1])
  y = []
  for i in range(len(x)):
    y = y + [x[i]*np.array([3,4,5])+np.array([-2,3,1])]
  y = np.array(y)
  err_y = np.array([[0.2,0.2,0.1],[0.2,0.2,0.1],[0.2,0.2,0.1],[0.2,0.2,0.1],[0.2,0.2,0.1]])
  </code></pre>