We help IT Professionals succeed at work.
Troubleshooting Question

# Find a curve that fits the data

on
59 Views
What's a neat way of finding the simplest polynomial or other form of curve that fits the data.
For example the following data points:

 X Y 0 0 1 1 2 5 3 6 4 6 5 5 6 3 7 2 8 1

Looking equally for an excel answer, or an online site that does it for me, ultimately I'm looking to code that in Python.
X is the input and might be any range of numbers.
Y is the output which will be between 0% and 100%

Comment
Watch Question

## View Solution Only

Research Engineer - Electrical
CERTIFIED EXPERT

Commented:
You need to decide what you mean by "fit".

You have nine data points.  You can define an 8th degree Lagrange Polynomial that will pass precisely through all of your points.  It is a straight forward but tedious process.  The resulting curve may behave eratically between points.
https://en.wikipedia.org/wiki/Lagrange_polynomial

You can also decide to fit your data to a simpler curve, and adjust parameters to minimize the error.  Maybe something like this:
https://en.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution

The shape of this curve is A*X² /exp(B*X² ).  In this example A =1.6 and B =0.04
Software Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
If you want to fit a curve you really need to decide on what curve to fit anyway. And then how you want to cope with "errors" ,  as you are looking for best fit.
Several methods do exist, like least difference, least squares of differences.
And decide on a single curve, of combination of curves like splines.

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)

Commented:
Thank you both, I'll look into those over the weekend.
Best wishes
Charles
CERTIFIED EXPERT

Commented:
Hi Charles,

Do you need any more help with this?

Regards,
Tomas Helgi

Commented:
Charles

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

###### Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

Deciding to stick with EE.

Mohamed Asif

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
###### Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE