title: Average trend curve for data points in Python
body: <p>I'd love to reproduce a plot similar to this:</p>
  
  <p><a href="https://i.stack.imgur.com/VIEYV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VIEYV.jpg" alt=""></a><br>
  <sub>(source: <a href="https://www.brleader.com/news/images/nothing1.jpg" rel="nofollow noreferrer">brleader.com</a>)</sub>  </p>
  
  <p>I mean I have a set of data points and I'd love to have a curve which shows the average trend.</p>
  
  <p>I tried adding random noise to the function y=2x</p>
  
  <pre><code>  from scipy import interpolate
  
    x=arange(0,1,1e-3)
    noise=np.random.random(len(x))
    y=2*x+noise
  </code></pre>
  
  <p>And then I used some of the Scipt function to interpolate data</p>
  
  <pre><code>  xnew=arange(0,1,1e-1)
    f=interpolate.UnivariateSpline(x,y)
    g=interpolate.interp1d(x,y)
    plot(x,y,'ro',xnew,f(xnew),'-',xnew,g(xnew),'--')
    show()
  </code></pre>
  
  <p>But the curve I get hardly resemble y=2*x. I'd love to have a smooth curve which average the data. Which method/function can I use?</p>