I am attempting to recreate some of the functionality of Excel. In Excel, I can list a set of x,y coordinates and get a trend line that has been interpolated from said points. I have figured out how to do this with Alglib by using the 'spline1dbuildakima' function.
Here is my problem: In excel you can choose to display the equation for the generated line. How can I do this with Alglib? I have been trying to interpret spline1dunpack but have been unable to decipher the output, and am not completely sure that I am heading in the right direction. I have confirmed that spline1dbuildakima is generating the correct line because I have tested it using spline1dcalc and it gives me the same answers for x and y that excel does. Below is the code I am using to generate the spline and I have also included the equation that excel gives me.
Any help would be incredible!!
Code:
double[] x = new double[] { 0, .0833, .1667, .2500, .3333, .4167, .5000, .5833, .6667, .7500, .8333, .9167, 1 };
double[] y = new double[] { 0, .0705, .1516, .2641, .4029, .5410, .6781, .7943, .9042, .9519, .9836, 1.0001, 1 };
alglib.spline1dinterpolant s;
double[,] tbl;
alglib.spline1dbuildakima(x, y, out s);
Excel Generated Formula: y = -3.7835x6 + 16.075x5 - 22.714x4 + 11.198x3 - 0.576x2 + 0.8x + 0.0004
spline1dunpack Generated Data below; each object in spline1dunpack is new line below
0
0.0833
0
0.78333458944077
0.756349891637399
0
0.0833
0.1667
0.0705
0.909342481387561
0.218848190553835
6.44486452138571
0.1667
0.25
0.1516
1.08032928518305
2.79880068138734
5.34247324050666
0.25
0.3333
0.2641
1.65782198113364
0.323658066682665
-2.66846591971681
0.3333
0.4167
0.4029
1.65619484058598
-0.00288634351093913
-0.0113319095767315
0.4167
0.5
0.541
1.65547693915743
0.114945343057455
-2.76608260064354
0.5
0.5833
0.6781
1.61704620462046
-5.09875644452016
29.2032573511532
0.5833
0.6667
0.7943
1.37550795216743
1.17650000824958
-22.4111717098455
0.6667
0.75
0.9042
1.10410140504906
-10.9086700546181
54.3631419609296
0.75
0.8333