Help with BiCubicSpline Interpolation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with BiCubicSpline Interpolation

Ahmad Mahomed
Hi ,

I am having some difficulty understanding and reconciling the results I get from using QLs BiCubicSpline Interpolation(2d) method. The results I am getting are vastly different to results from another propriety library (which I believe is a simple wrapper of Matlab's 2d interpolation method (http://www.mathworks.com/help/techdoc/ref/interp2.html). Using a "linear" interpolation method produces the same result from both libraries

I suspect that QL's implementation is different - my questions are:
1) What are the differences if any? 
2) Using QuantLib, how can I get a similar results comparable to Matlab's interp2 function (using the spline option)?

I have attached a file(csv) showing the results.

Thanks
--
Ahmad Mahomed

------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits?
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

BiCubic Interpolation.csv (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help with BiCubicSpline Interpolation

Luigi Ballabio
As far as I see from the code, QuantLib's implementation uses a set of
splines to interpolate over x and get a set of point f(x, y_i) and
then interpolates over y on those to get f(x,y).  In both cases, it
uses boundary conditions that set the second derivative to 0 on the
boundaries.  What does Matlab use?

Luigi

On Wed, Dec 14, 2011 at 6:49 AM, Ahmad Mahomed <[hidden email]> wrote:
> I am having some difficulty understanding and reconciling the results I get
> from using QLs BiCubicSpline Interpolation(2d) method. The results I am
> getting are vastly different to results from another propriety library
> (which I believe is a simple wrapper of Matlab's 2d interpolation method
> (http://www.mathworks.com/help/techdoc/ref/interp2.html). Using a "linear"
> interpolation method produces the same result from both libraries

------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity
while improving strategic productivity.  Learn More!
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Help with BiCubicSpline Interpolation

Ahmad Mahomed
Hi Luigi,

I did manage to sort this out and find out what Matlab uses. Matlab use the "Not-a-Knot" boundary conditions which I managed to figure out use the QL Excel Addin spreadsheet demos.

I updated my local version of QL to include this additional interpolation method, but would like to know whether it would be preferable to add this to the QL trunk or maybe modify the current 2d Interpolation to accept a custom cubic spline object (or possibly the end boundary conditions)?

Ahmad

On 15 December 2011 14:18, Luigi Ballabio <[hidden email]> wrote:
As far as I see from the code, QuantLib's implementation uses a set of
splines to interpolate over x and get a set of point f(x, y_i) and
then interpolates over y on those to get f(x,y).  In both cases, it
uses boundary conditions that set the second derivative to 0 on the
boundaries.  What does Matlab use?

Luigi

On Wed, Dec 14, 2011 at 6:49 AM, Ahmad Mahomed <[hidden email]> wrote:
> I am having some difficulty understanding and reconciling the results I get
> from using QLs BiCubicSpline Interpolation(2d) method. The results I am
> getting are vastly different to results from another propriety library
> (which I believe is a simple wrapper of Matlab's 2d interpolation method
> (http://www.mathworks.com/help/techdoc/ref/interp2.html). Using a "linear"
> interpolation method produces the same result from both libraries



--
Ahmad Mahomed

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Help with BiCubicSpline Interpolation

Luigi Ballabio
On Mon, Feb 20, 2012 at 7:53 AM, Ahmad Mahomed <[hidden email]> wrote:
> I did manage to sort this out and find out what Matlab uses. Matlab use the
> "Not-a-Knot" boundary conditions which I managed to figure out use the QL
> Excel Addin spreadsheet demos.
>
> I updated my local version of QL to include this additional interpolation
> method, but would like to know whether it would be preferable to add this to
> the QL trunk or maybe modify the current 2d Interpolation to accept a custom
> cubic spline object (or possibly the end boundary conditions)?

Hi Ahmad,
    I'd prefer to modify the existing interpolation. Passing all the
parameters specifying the boundary conditions might be a bit verbose,
so you might try passing two instances of the Cubic struct instead.
But either way would work for me.

Luigi

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Help with BiCubicSpline Interpolation

Ahmad Mahomed
Hi Luigi,

I will submit a patch after the 1.2 release. However if you prefer, make it part of the next release?

BTW - I read on a different thread about the move to a DVCS? Any ETA on this?
 
Ahmad

On 28 February 2012 16:11, Luigi Ballabio <[hidden email]> wrote:
On Mon, Feb 20, 2012 at 7:53 AM, Ahmad Mahomed <[hidden email]> wrote:
> I did manage to sort this out and find out what Matlab uses. Matlab use the
> "Not-a-Knot" boundary conditions which I managed to figure out use the QL
> Excel Addin spreadsheet demos.
>
> I updated my local version of QL to include this additional interpolation
> method, but would like to know whether it would be preferable to add this to
> the QL trunk or maybe modify the current 2d Interpolation to accept a custom
> cubic spline object (or possibly the end boundary conditions)?

Hi Ahmad,
   I'd prefer to modify the existing interpolation. Passing all the
parameters specifying the boundary conditions might be a bit verbose,
so you might try passing two instances of the Cubic struct instead.
But either way would work for me.

Luigi



--
Ahmad Mahomed

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Help with BiCubicSpline Interpolation

Luigi Ballabio
On Mon, Mar 5, 2012 at 6:48 AM, Ahmad Mahomed <[hidden email]> wrote:
> I will submit a patch after the 1.2 release. However if you prefer, make it
> part of the next release?

It will go in after 1.2.  You can send it at any time, however.

> BTW - I read on a different thread about the move to a DVCS? Any ETA on
> this?

Not really.  I'd like to do it, but it's still just an idea floating around.

Thanks,
    Luigi

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users