forum.alglib.net
http://forum.alglib.net/

Interpolation
http://forum.alglib.net/viewtopic.php?f=2&t=374
Page 1 of 1

Author:  favour [ Thu Jun 02, 2011 4:55 pm ]
Post subject:  Interpolation

Hi every one,
I need to use Spline&& polynomial && regression interpolation in C#.
how can i do that? is there any example to help me?
Thankssss

Author:  Sergey.Bochkanov [ Thu Jun 02, 2011 6:02 pm ]
Post subject:  Re: Interpolation

You can find some information in the ALGLIB Reference Manual:

http://www.alglib.net/translator/man/ma ... t_spline1d
http://www.alglib.net/translator/man/ma ... nit_polint
http://www.alglib.net/translator/man/ma ... unit_lsfit

If you still have questions, feel free to ask them here.

Author:  favour [ Fri Jun 03, 2011 2:58 am ]
Post subject:  Re: Interpolation

Many thanks :)
I actually impressed when i saw this powerful library.
I have two question at the moment :
1- I entered this code :
Code:
alglib.spline1dinterpolant output;
            double[] x = new double[] { -2, -1, 0, 1, 2 };
            double[] y = new double[] { 4, 1, 0, 1, 4 };

            alglib.spline1dbuildakima(x, y, out output);


The out put is {4,-4,1,0,1,-2,1,0,0,0,1,0,1,2,1,0}. it means that my equation curve is :
f(x) = 4 - 4x + x^2 +x^4 - 2x^5 + x^9 + x^11 + 2x^12 + x^13 ???

2- My second question is about my request:
I have 2 arrays x and y which show the coordinate. the distance between them are not same. Which function is then best fit Spline Interpolation equation for me?

Thanks
Regards

Author:  Sergey.Bochkanov [ Fri Jun 03, 2011 10:42 am ]
Post subject:  Re: Interpolation

1. you should not work with contents of spline1dinterpolant structure directly - use ALGLIB functions to work with it. In particular, if you want to extract coefficients - use spline1dunpack - it provides convenient and 100% documented interface

2. you can use parabolically terminated cubic splines

Author:  favour [ Sat Jun 04, 2011 4:52 am ]
Post subject:  Re: Interpolation

Thanks for your help
i have gotten one run-time error "Exception of type 'alglib+alglibexception' was thrown"
i used
Code:
alglib.spline1dgriddiffcubic(mainPointX, mainPointY, out d1);
the mainPointX and mainPointY have 31 double numbers.
The numbers are :
Code:
double[] mainPointX = new double[] { 19, 20.5, 57, 144, 148, 154.5, 158.5, 178, 197.5, 269, 350, 379, 409, 473, 477.5, 485, 493, 497, 534.5, 572.5, 579, 584.5, 590, 605, 608, 609, 609, 609, 609, 609, 609 };
            double[] mainPointY= new double[] { 99, 92.5, 91.5, 92.5, 92.5, 92.5, 92.5, 93.5, 93.5, 95.5, 96.5, 97.5, 97.5, 98.5, 98.5, 98.5, 98.5, 98.5, 99.5, 99.5, 99.5, 99.5, 99.5, 101.5, 103.5, 105.5, 107.5, 109.5, 111.5, 113.5, 115.5 };


what is wrong for me to get this error?
Regards

Author:  Sergey.Bochkanov [ Sat Jun 04, 2011 6:59 am ]
Post subject:  Re: Interpolation

alglib.alglibexception class has msg field. If you read it, you will find description of situation which caused you program to abort. It tells that you have incorrect mainPointX - array size is correct, but data it holds are not. Several last elements are not distinct.

Author:  favour [ Mon Jun 06, 2011 11:20 am ]
Post subject:  Re: Interpolation

Yup your correct my numbers weren't distinct. Thanks

Now i am looking for polynomial Regression, i used polynomialfit procedure to find equation line in n=4 for example.
but i dont know how i can get equation line. the out parameter ( or 'p') is barycentric type. it has some parameters in the structure.
which function can interpret this structure and the give me an equation line?

another question is that, i want first deviation and second derivation values. In spline interpolation i used spline1dgriddiffcubic and spline1dgriddiff2cubic , which function here can easily give me these values?

Thanks a lot
Regards

Author:  Sergey.Bochkanov [ Mon Jun 06, 2011 1:40 pm ]
Post subject:  Re: Interpolation

barycentricbar2pow will convert your polynomial into power basis
barycentricdiff can be used to calculate first derivative
barycentricdiff2 can be used to calculate second derivative

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/