title: Fitting a curve without knowing function type in python
body: <p>I'm trying to fit a smooth curve to a set of data that's very noisy. By using the &quot;UnivariateSpline&quot; function from scipy I have almost managed to reach my goal, but the fitting of the curve seems to not be able to fit the beginning correctly.
  The first picture shows the whole plot (red is the fitted curve, green the noisy data).</p>
  <p><em>First plot</em><br />
  <img src="https://i.stack.imgur.com/Cvv2J.png" alt="First plot" /></p>
  <p>The second picture is zoomed in on the part that the fitting gets wrong.</p>
  <p><em>Second plot with the fitting error</em><br />
  <img src="https://i.stack.imgur.com/luOh8.png" alt="Second plot with the fitting error" /></p>
  <p>Does anyone have an idea for how to make this more aligned with the green data?</p>
  <p>I have tried splitting up the first part of the data (from x=0 to the spike,  an exponential-like curve) and the second part from the top of the spike and out (a negative exponential function).  But this didn't work.</p>
  <p>In the end, the important thing is to always have increasing values of y with increasing x before the spike, and the opposite with increasing x after the spike.</p>