1
$\begingroup$

I have this iPhone app that has an array containing around 50 to 100 points. How do I calculate the smoothest curve that will fit the points? It can be bezier, cubic, quadratic, whatever. It just have to look smooth and fit as much as possible all points (obviously, as I did in my drawing, to create a smooth curve, some points have to be created out of the original set... no problem).

Can you guys please point me to a code is Objective-C, C or C++?

See an image here, to know what I mean: http://i.stack.imgur.com/UoRQB.png

thanks

  • 2
    Ask on stackoverflow instead.2011-06-06

2 Answers 2

1

People usually use Spline Interpolation.

  • 0
    @Mike: This method is so standard that I'm sure you can google an implementation by yourself.2011-06-07
1

What you want is LOWESS, or LOcally WEighted Scatterplot Smoothing. This performs a sequence of weighted linear regressions as you move along the curve, assigning more weight to nearby points and less to far away points. Read about it here.

This is implemented in the open-source statistics package R, as the function lowess. I don't know if someone has implemented it in C, C++ or Objective-C but you could take a look at the R code and work from there.

Here's a quick plot that I made in R: enter image description here