Fitting the best curve to the data

1 view (last 30 days)
Abdullah Alsharef
Abdullah Alsharef on 16 Jun 2015
Commented: Abdullah Alsharef on 25 Jun 2015
I'm trying to fit the best curve to my data that produces a function by minimizing the SSE. The behavior of my data is: as x-datapoints increase y-datapoints either increase or stays the same. Additionally, my data points are in the range between zero and 100. I want the curve to start at (0,0) and pass (100,100) and try to minimize SSE. All matlab statistical fitting didn't work.

Answers (1)

John D'Errico
John D'Errico on 16 Jun 2015
I'm not going to be able to check back in about this question for a day, but the answer is simple in general. Of course, I have no idea why you failed to get a result, but I could hazard some guesses. There could be so many reasons why you failed to get a result to make you happy, so if I DID try to guess, I'd surely guess wrong.
Anyway, use my SLM toolbox. This is exactly that it is designed to do. You can force the curve to pass through those endpoints. Just as a rough guess, your call might like like this:
slm = slmengine(x,y,'knots',0:10:100,'leftvalue',0,'rightvalue',100,'increasing','on','plot','on');
You can choose other knots of course, as long as they go from 0 to 100. And you can decide not to plot the result automatically, but I ALWAYS recommend looking at the result.
Find SLM on the file exchange for download.
  1 Comment
Abdullah Alsharef
Abdullah Alsharef on 25 Jun 2015
First of all, I'd like to thank you for your answer. I used your toolbox and it solved the first issue which is forcing the curve to pass through the desired points. I used the the following line to produce the figure:
slm=slmengine(X,y,'plot','on','increasing','on','rightvalue',100,'leftvalue',0,'knots',[0 100]);
and it produced the following figure:
My question is now: How can I generate the prediction function for this curve such as this function f(x) = p1*x^3 + p2*x^2 + p3*x + p4
Thank you so much again for your assistance.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!