I have an object for InterpolatedForwardCurve and I try to calculate implied discount rate. The implementation calls InterpolatedForwardCurve<T>::zeroYieldImpl. template <class T> My code runs into integral = this->interpolation_.primitive(t, true); The implementation for the primitive function is: Real primitive(Real x) const { Let's say my curve defines for {t1, t2, t3, t4}. I try to calculate discount rate at t2. Q1: I think the code is trying to do numerical integration from t2 to t3. Am I correct? Q2: What numerical integration technique is it using? I can't relate the code with the techniques defined in wikipedia for numerical integration. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Ted,
In zeroYieldImpl(Time t) the integral from 0 to t over the instantaneous forward rate is computed (to get the zero yield times t at t), in your example this would be the integral from 0 to t2, not from t2 to t3. The integration uses the primitive function (i.e. the function F with F(x0)=0 and whose derivative is the interpolating function) provided by the interpolation. In your case it seems to be LinearInterpolation. Now the interpolation could in general use a numerical integration scheme, but in the case of a linear interpolation it is of course much more efficient to code the primitive function directly, which is done in the second code snippet you posted (the primitiveConst_ values are precomputed in the update() method). Best Peter
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |