title: How to fit parametric equations to data points in Python
body: <p>I am looking for a way to fit
  <a href="https://en.wikipedia.org/wiki/Parametric_equation" rel="nofollow">parametric equations</a> to a set of data points, using Python.</p>
  
  <p>As a simple example, given is the following set of data points:</p>
  
  <pre><code>import numpy as np
  x_data = np.array([1, 2, 3, 4, 5])
  y_data = np.array([2, 0, 3, 7, 13])
  </code></pre>
  
  <p>Using <code>t</code> as the parameter, I want to fit the following parametric equation to the data points,</p>
  
  <pre><code>t = np.arange(0, 5, 0.1)
  x = a1*t + b1
  y = a2*t**2 + b2*t + c2
  </code></pre>
  
  <p>that is, have Python find the values for the coefficients <code>a1</code>, <code>b1</code>, <code>a2</code>, <code>b2</code>, <code>c2</code> that fits <code>(x,y)</code> best to the data points <code>(x_data, y_data)</code>.</p>
  
  <p>Note that the <code>y(t)</code> and <code>x(t)</code> functions above only serve as examples of parametric equations. The actual functions I want to fit my data to are much more complex, and in those functions, it is not trivial to express <code>y</code> as a function of <code>x</code>.</p>
  
  <p>Help will be appreciated - thank you!</p>