You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Nico Caprioli <ni...@gmail.com> on 2013/08/22 17:02:34 UTC

[math] SplineInterpolator not working properly

Since I need a spline interpolation I used your library do calculate it but
it seems it is not working good.

If I understood javadoc i need two double[] arrays:
- double[] x: the absissa of every point
- double[] y: the ordinate/value of points in the same order of x

Now after interpolation I try to print it through:
System.out.println(Arrays.toString(interpolation.getPolynomials()));
where interpolation is the PolynomialSplineFunction generated.

It outputs some functions but only the first is correct, why?

Thank you!

Re: [math] SplineInterpolator not working properly

Posted by Nico Caprioli <ni...@gmail.com>.
Forget everything i told, i found my problem:
System.out.println(Arrays.toString(interpolation.getPolynomials())
gives me not-centered function, if I translate them to right of the right
step (in my case 0 for the first, 1 for the second, 2 for the third and so
on) i get right spline functions!

Regards,
Nico


2013/8/22 Nico Caprioli <ni...@gmail.com>

> I've attached a simple java file that interpolates and prints functions
> (results on second files)
> I expected at least to have a continue function
>
> Moreover I catched x and y values from wikipedia that gives this functions
> for natural cubic spline with theese points
> http://upload.wikimedia.org/math/9/a/7/9a712abc0f13501fd9ccbd1dae69789a.png
>
> Thank you,
> Nico
>
>
> 2013/8/22 Gilles <gi...@harfang.homelinux.org>
>
>> On Thu, 22 Aug 2013 17:02:34 +0200, Nico Caprioli wrote:
>>
>>> Since I need a spline interpolation I used your library do calculate it
>>> but
>>> it seems it is not working good.
>>>
>>> If I understood javadoc i need two double[] arrays:
>>> - double[] x: the absissa of every point
>>> - double[] y: the ordinate/value of points in the same order of x
>>>
>>> Now after interpolation I try to print it through:
>>> System.out.println(Arrays.**toString(interpolation.**getPolynomials()));
>>> where interpolation is the PolynomialSplineFunction generated.
>>>
>>> It outputs some functions but only the first is correct, why?
>>>
>>> Thank you!
>>>
>>
>> From the above information, it is hard to figure out what you did,
>> what you expected and what you got.
>> Please attach a minimal, but working, code example.
>>
>> Regards,
>> Gilles
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

Re: [math] SplineInterpolator not working properly

Posted by Nico Caprioli <ni...@gmail.com>.
I've attached a simple java file that interpolates and prints functions
(results on second files)
I expected at least to have a continue function

Moreover I catched x and y values from wikipedia that gives this functions
for natural cubic spline with theese points
http://upload.wikimedia.org/math/9/a/7/9a712abc0f13501fd9ccbd1dae69789a.png

Thank you,
Nico


2013/8/22 Gilles <gi...@harfang.homelinux.org>

> On Thu, 22 Aug 2013 17:02:34 +0200, Nico Caprioli wrote:
>
>> Since I need a spline interpolation I used your library do calculate it
>> but
>> it seems it is not working good.
>>
>> If I understood javadoc i need two double[] arrays:
>> - double[] x: the absissa of every point
>> - double[] y: the ordinate/value of points in the same order of x
>>
>> Now after interpolation I try to print it through:
>> System.out.println(Arrays.**toString(interpolation.**getPolynomials()));
>> where interpolation is the PolynomialSplineFunction generated.
>>
>> It outputs some functions but only the first is correct, why?
>>
>> Thank you!
>>
>
> From the above information, it is hard to figure out what you did,
> what you expected and what you got.
> Please attach a minimal, but working, code example.
>
> Regards,
> Gilles
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [math] SplineInterpolator not working properly

Posted by Gilles <gi...@harfang.homelinux.org>.
On Thu, 22 Aug 2013 17:02:34 +0200, Nico Caprioli wrote:
> Since I need a spline interpolation I used your library do calculate 
> it but
> it seems it is not working good.
>
> If I understood javadoc i need two double[] arrays:
> - double[] x: the absissa of every point
> - double[] y: the ordinate/value of points in the same order of x
>
> Now after interpolation I try to print it through:
> System.out.println(Arrays.toString(interpolation.getPolynomials()));
> where interpolation is the PolynomialSplineFunction generated.
>
> It outputs some functions but only the first is correct, why?
>
> Thank you!

 From the above information, it is hard to figure out what you did,
what you expected and what you got.
Please attach a minimal, but working, code example.

Regards,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org