Natural Cubic Spline Function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Natural Cubic Spline Function

amandine vincotte
Hi ,

I am trying to get a Cubic Spline Function and I have created the simple function below using "Natural Cubic Spline".

But from the output below it looks more like a flat filled curve.


Am I missing anything?


Thank you for you help.

Regards,


Amandine







void test(const Date& valueDate)
{
 vector<Rate> x;
 vector<Rate> y;
 x.push_back(0.05);
 y.push_back(2);
 x.push_back(0.1);
 y.push_back(2.3);
 x.push_back(0.15);
 y.push_back(1.5);
 x.push_back(0.2);
 y.push_back(1);
 x.push_back(0.25);
 y.push_back(3.1);
 NaturalCubicSpline sp(x.begin(),x.end(),y.begin());
 Rate r=0.07;
 while(r<=0.25)
 {
  Rate rr = sp(r,true);
  cout << r << "," << rr << endl;
  r+=0.01;
 }
}


OUTPUT:

0.07,2
0.08,2
0.09,2
0.1,2
0.11,2.3
0.12,2.3
0.13,2.3
0.14,2.3
0.15,1.5
0.16,1.5
0.17,1.5
0.18,1.5
0.19,1.5
0.2,1
0.21,1
0.22,1
0.23,1
0.24,1

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users