Interface for Smoother Cost Function decorator. More...

#include <SmootherCostFunction.hpp>

Inheritance diagram for julian::ir::SmootherCostFunction:
julian::ir::CostFunctionDecorator julian::ir::SmoothForwardRates julian::ir::SmoothZeroCouponRates julian::ir::FirstDerivativeCostFunction julian::ir::SecondDerivativeCostFunction

Public Member Functions

 SmootherCostFunction ()
 constructor More...
 
virtual arma::mat giveQmatrix (const InterpolatedCurve &) const =0
 returns Q matrix, the quadratic term of optimization cost function More...
 
virtual arma::mat giveCvector (const InterpolatedCurve &) const =0
 returns C vector, the linear term of optimization cost function More...
 
virtual double calculateCost (const InterpolatedCurve &) const =0
 calculates value of cost function More...
 
virtual std::vector< double > giveSmoothedCurve (const InterpolatedCurve &) const =0
 returns curve as vector of doubles More...
 
virtual void updateSmoothedCurve (InterpolatedCurve &, const std::vector< double > &) const =0
 updates the curve as with the vector of doubles More...
 
virtual SmootherCostFunctionclone () const =0
 virtual copy constructor More...
 
virtual ~SmootherCostFunction ()
 destructor More...
 

Detailed Description

Interface for Smoother Cost Function decorator.

The SmootherCostFunction is used by ir::InterpolatedCurve estimators that base on optimization techniques. SmootherCostFunction implements the cost function that is minimized in optimization algorithm. Generally the cost function $f(x)$ is given by formula

\[Cost_{f} = a \int^{tN}_{t0} \Big(\frac{df(x)}{dx}\Big)^2 dx + b \int^{tN}_{t0} \Big(\frac{df^2(x)}{dx^2}\Big)^2 dx \]

where:

  • $x$ is a curve representation, it can be zero-coupon rate or forward rates. It is selected by using appropriate concrete component in decorator structure. Concrete Component is a class that contains basic behaviour that can be altered by decorators.
  • $a, b$ are weights, can be set to 0. These components and weights are set by selecting appropriate concrete decorator. Concrete Decorator is a class that altered alters the behaviour of Concrete Component.
  • $t0,tN$ are respectively the earliest and the latest grid date of the curve

If we want to estimate discounting curve by finding the shortest curve of zero-coupon rates, we simply choose the SmoothZeroCouponRates as concrete component and FirstDerivativeCostFunction as concrete decorator, as minimizing the integral $\int^{t0}_{tN} \Big(\frac{df(x)}{dx}\Big)^2 dx$ is equivalent to minimizing the integral $\int^{tN}_{t0} \Big(\sqrt{1-\frac{df(x)}{dx}\Big)^2} dx$ which express the length of the curve. If we want to minimize the function variance we should choose the SecondDerivativeCostFunction as decorator class. Thanks to using the Decorator Pattern defining the cost function is flexible and simple.

It is worth noting that algorithm does not evaluate integrals exactly. Numerical approximation is used. We calculate the first and second derivative numerically

\[ \int^{tN}_{t0} \Big(\frac{df(x)}{dx}\Big)^2 dx \approx \sum^{i=N-1}_{i=0}\Big(\frac{x(t_{i+1}) - x(t_{i})}{t_{i+1}-t_i}\Big)^2 = x^T D^T_1D_1 x = x^T Q x\]

where $D_1$ is a matrix representing first order differentiation and $t_i$ are grid dates of the curve.

Examples:
constrainedBootstrapperExample.cpp, and unconstrainedBootstrapperExample.cpp.

Constructor & Destructor Documentation

julian::ir::SmootherCostFunction::SmootherCostFunction ( )
inline

constructor

virtual julian::ir::SmootherCostFunction::~SmootherCostFunction ( )
inlinevirtual

destructor

Member Function Documentation

virtual double julian::ir::SmootherCostFunction::calculateCost ( const InterpolatedCurve ) const
pure virtual
virtual arma::mat julian::ir::SmootherCostFunction::giveCvector ( const InterpolatedCurve ) const
pure virtual
virtual arma::mat julian::ir::SmootherCostFunction::giveQmatrix ( const InterpolatedCurve ) const
pure virtual
virtual std::vector<double> julian::ir::SmootherCostFunction::giveSmoothedCurve ( const InterpolatedCurve ) const
pure virtual
virtual void julian::ir::SmootherCostFunction::updateSmoothedCurve ( InterpolatedCurve ,
const std::vector< double > &   
) const
pure virtual

updates the curve as with the vector of doubles

Implemented in julian::ir::SmoothForwardRates, julian::ir::SmoothZeroCouponRates, and julian::ir::CostFunctionDecorator.


The documentation for this class was generated from the following file: