Page 1 of 2

[Solved] Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 5:07 pm
by VB6_to_PBx
is there a Curve Fit equation more accurate in regards to X and Y Data pairs
than a Cubic Spline Curve Fit ??

Reason : Cubic Splines are not a good enough Fit to Data i'm trying to simulate

TSpline, BSpline, CSpline, Bezier , others ...etc ??

Anyone have PureBasic Code for Curve Fits they would share ?

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 5:41 pm
by skywalk
How do you define accuracy in your curve fits?
Do you have a csv file of xy data for the many points(curve fitted) vs a smaller data set(original)?

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 7:17 pm
by STARGÅTE
Do you want to fit your data with an equation, a law? Than you have to look for your law: Exp(), Sin(), Sqr() ...
Do you want to interpolate your data, with a polynom? In the easiest case linear.

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 7:56 pm
by VB6_to_PBx
STARGÅTE wrote:Do you want to fit your data with an equation, a law? Than you have to look for your law: Exp(), Sin(), Sqr() ...
Do you want to interpolate your data, with a polynom? In the easiest case linear.
skywalk wrote: How do you define accuracy in your curve fits?
Do you have a csv file of xy data for the many points(curve fitted) vs a smaller data set(original)?
thanks for the quick Replies ... didn't think i'd get so quick a response ,
i'll Post or Link a X,Y Data File in csv format

Polynomial and a Linear Spline i've tried , and are not close enough fit
a Cubic Spline is closer , but still not close enough

i'm testing so far only 33 X Y Data pairs to fit 1300 to 1600 Data points to minimum of 5 decimal places

i've writen a Program that generates minimum of 1300+ points of Data in 5 to 6 decimal places accuracy
and i'm trying to reverse-engineer the Data of that Program back into original accuracy over 1300+ points .

i'm trying to do this without necessarily having to add a bunch more than 33 XY Data points
in other words, trying to keep somewhere around 130 or less XY Data pairs that will accurately simulate 1300+ real points of Data to 5 r more decimal places

i thought i would Post a Thread here to see if anyone know of a Spline or anyother Curve Fit equations
that might use 30 to 100 or even as high as 200 XY Data pairs to simulate real 1300 Data point values to 5 or 6 decimal places minimum.

dividing up 1300 points into 100 or so Cubic Spline XY Data pairs is what i was going to test next
while waiting on anyone in this Forum to Reply with a better more accurate Solution

Thanks for interest + any Code to test out

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 9:17 pm
by DarkDragon
For every type of spline there are two possibilities:
  1. use the data as control points (curve does not go through the points)
  2. interpolate the data points (curve goes through it)
However with many points, you'll experience the problem of overfitting, which means that the curve will create waves with unwanted huge waves. B-splines try to limit these for example by limiting the influence of control points (or better said knots).

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 9:22 pm
by skywalk
You just need the XY pairs for the region of the curve that deviates from your attempted curve fit.

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Fri Mar 01, 2019 10:40 pm
by VB6_to_PBx
However with many points, you'll experience the problem of overfitting,
which means that the curve will create waves with unwanted huge waves.
B-splines try to limit these for example by limiting the influence of control points (or better said knots).
which means that the curve will create waves with unwanted huge waves.

Yes, that's exactly what is happening !!! ... but using lesser XY Data pairs does not help out either :evil:

with a Cubic Spline , it fits perfect in some portions and then wildly deviates in other portions... then comes back again in the next portions with a perfect fit to 6+ decimal point places

i'm trying to correct the deviation section problems with a more accurate Curve Fit equation or Method
i have B-Spline equations in VB6.0 , but must convert to PureBasic plus add all the extra XY data Pair inputs
as VB6 version only has 5 XY Data pairs

so you think B-Spline might help ??

i have VB6 T and C Spline equations , but they also have 5 XY Data pair input boxes, so it takes time to code for 30+ XY Pairs
and test these different Splines in PureBasic or VB6
You just need the XY pairs for the region of the curve that deviates from your attempted curve fit.
thats same idea i've had .. just did not yet get to test that out too :(
will start coding all this in ....

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sat Mar 02, 2019 6:05 pm
by VB6_to_PBx
well none of the various Splines worked at all :(

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sat Mar 02, 2019 6:09 pm
by skywalk
Can you cut and paste some XY values?
Better yet, embed them in a DataSection?

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sat Mar 02, 2019 9:15 pm
by VB6_to_PBx
skywalk wrote:Can you cut and paste some XY values?
Better yet, embed them in a DataSection?
i placed actual Data files in Excel .XLS format
with .PNG picture files
and .TXT files
of problems fitting Cubic Spline Data -VS- Real Data
in this ZIP File Link :

http://www.mediafire.com/file/0d4fm4rns ... s.zip/file

sorry i have not yet coded a PureBasic program
to use XY Pairs in a DataSection to Post or include in the ZIP file

Please read the README.TXT file first .

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sat Mar 02, 2019 9:56 pm
by skywalk
As I suspected, you have discontinuities in the data set that cannot reasonably be described with simple polynomials or cubics. You have to create a model that emits data for these crossover points.

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sat Mar 02, 2019 10:15 pm
by VB6_to_PBx
skywalk wrote:As I suspected, you have discontinuities in the data set that cannot reasonably be described with simple polynomials or cubics. You have to create a model that emits data for these crossover points.
Yes ,
and it appears it would take a ton of XY Data Pairs to get a thorough accurate Fit at each point ,
in doing so , defeats the purpose of Curve Fitting

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Sun Mar 03, 2019 12:59 pm
by jack
hello VB6_to_PBx
there's program called Eureqa https://www.nutonian.com/download/eureq ... -download/ that tries to find a symbolic expression to a given set of data points
who knows, it may help in your situation.
the program initially was free, but not anymore, and I haven't run the program since then, there's however a 30 day trial version for download.
[edit]
Eureqa was bought out by https://www.datarobot.com/

youtube demo https://www.youtube.com/watch?time_cont ... hC1Qb-PQ5Q
https://www.youtube.com/watch?v=k7GCqfV5Uk4
https://www.youtube.com/watch?time_cont ... So6eeDsFlE

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Mon Mar 04, 2019 6:08 am
by VB6_to_PBx
jack wrote:hello VB6_to_PBx
there's program called Eureqa https://www.nutonian.com/download/eureq ... -download/ that tries to find a symbolic expression to a given set of data points
who knows, it may help in your situation.
the program initially was free, but not anymore, and I haven't run the program since then, there's however a 30 day trial version for download.
[edit]
Eureqa was bought out by https://www.datarobot.com/

youtube demo https://www.youtube.com/watch?time_cont ... hC1Qb-PQ5Q
https://www.youtube.com/watch?v=k7GCqfV5Uk4
https://www.youtube.com/watch?time_cont ... So6eeDsFlE
thanks Jack for the Links ,

i've downloaded it , but have not run it yet,
and it might give me some insights , but not completely solve what i want ?

Re: Curve Fits more accurate than Cubic Spline ?

Posted: Mon Mar 04, 2019 7:34 pm
by alter Mann
How do you choose the x-values, where the splines should start and end?