Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Parametrization Class Reference

Parametrization. More...

#include <qle/models/parametrization.hpp>

+ Inheritance diagram for Parametrization:
+ Collaboration diagram for Parametrization:

Public Member Functions

 Parametrization (const Currency &currency, const std::string &name="")
 
virtual ~Parametrization ()
 
virtual const Currency & currency () const
 
virtual const Array & parameterTimes (const Size) const
 
virtual Size numberOfParameters () const
 
virtual Array parameterValues (const Size) const
 
virtual const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const
 
virtual void update () const
 
const std::string & name () const
 
virtual Real direct (const Size, const Real x) const
 
virtual Real inverse (const Size, const Real y) const
 

Protected Member Functions

Time tr (const Time t) const
 
Time tl (const Time t) const
 
Time tr2 (const Time t) const
 
Time tm2 (const Time t) const
 
Time tl2 (const Time t) const
 

Protected Attributes

const Real h_
 
const Real h2_
 

Private Attributes

Currency currency_
 
std::string name_
 
const Array emptyTimes_
 
const QuantLib::ext::shared_ptr< Parameter > emptyParameter_
 

Detailed Description

Parametrization.

Base class for classes representing model parameters. There is a disctinction between "actual" and "raw" parameters. The "actual" parameter value is the true value of the parameter, e.g. 0.20 to represent a black scholes volatility of 20%. The "raw" parameter is derived from the actual parameter by applying a transformation

actual value = direct( raw value ) raw value = inverse( actual value )

The idea behind that is that the optimization during a model calibration can be performed as an unconstrained optimization which usually works more stable and is faster than a constrained optimization. For example, to ensure a positive black volatility one can use the transformation

direct ( x ) = x * x

To ensure a valid correlation one can use the transformation

direct ( x ) = (atan( x ) + pi / 2) / pi

and so forth. To implement you own transformation you can overwrite the direct() and inverse() methods. The default implementation of these methods represents the trivial transformation (identity, i.e. direct( x ) = x ).

Definition at line 57 of file parametrization.hpp.

Constructor & Destructor Documentation

◆ Parametrization()

Parametrization ( const Currency &  currency,
const std::string &  name = "" 
)

Definition at line 23 of file parametrization.cpp.

24 : h_(1.0E-6), h2_(1.0E-4), currency_(currency), name_(name), emptyParameter_(QuantLib::ext::make_shared<NullParameter>()) {}
const std::string & name() const
const QuantLib::ext::shared_ptr< Parameter > emptyParameter_
virtual const Currency & currency() const

◆ ~Parametrization()

virtual ~Parametrization ( )
virtual

Definition at line 60 of file parametrization.hpp.

60{}

Member Function Documentation

◆ currency()

const Currency & currency ( ) const
virtual

the currency associated to this parametrization

Definition at line 124 of file parametrization.hpp.

124{ return currency_; }

◆ parameterTimes()

const Array & parameterTimes ( const  Size) const
virtual

◆ numberOfParameters()

virtual Size numberOfParameters ( ) const
virtual

the number of parameters in this parametrization

Reimplemented in CirppParametrization< TS >, CommoditySchwartzParametrization, EqBsParametrization, FxBsParametrization, HwParametrization< TS >, InfJyParameterization, and Lgm1fParametrization< TS >.

Definition at line 69 of file parametrization.hpp.

69{ return 0; }

◆ parameterValues()

Array parameterValues ( const Size  i) const
virtual

the actual parameter values

Definition at line 130 of file parametrization.hpp.

130 {
131 const Array& tmp = parameter(i)->params();
132 Array res(tmp.size());
133 for (Size ii = 0; ii < res.size(); ++ii) {
134 res[ii] = direct(i, tmp[ii]);
135 }
136 return res;
137}
virtual const QuantLib::ext::shared_ptr< Parameter > parameter(const Size) const
virtual Real direct(const Size, const Real x) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parameter()

const QuantLib::ext::shared_ptr< Parameter > parameter ( const  Size) const
virtual

◆ update()

void update ( ) const
virtual

this method should be called when input parameters linked via references or pointers change in order to ensure consistent results

Reimplemented in EqBsPiecewiseConstantParametrization, FxBsPiecewiseConstantParametrization, HwParametrization< TS >, InfJyParameterization, Lgm1fParametrization< TS >, Lgm1fPiecewiseConstantHullWhiteAdaptor< TS >, Lgm1fPiecewiseConstantParametrization< TS >, and Lgm1fPiecewiseLinearParametrization< TS >.

Definition at line 108 of file parametrization.hpp.

108{}
+ Here is the caller graph for this function:

◆ name()

const std::string & name ( ) const

return a name (inflation index, equity name, credit name, etc.)

Definition at line 83 of file parametrization.hpp.

83{ return name_; }

◆ direct()

Real direct ( const  Size,
const Real  x 
) const
virtual

◆ inverse()

Real inverse ( const  Size,
const Real  y 
) const
virtual

◆ tr()

Time tr ( const Time  t) const
protected

adjusted central difference scheme

Definition at line 110 of file parametrization.hpp.

110{ return t > 0.5 * h_ ? t + 0.5 * h_ : h_; }
+ Here is the caller graph for this function:

◆ tl()

Time tl ( const Time  t) const
protected

Definition at line 112 of file parametrization.hpp.

112{ return std::max(t - 0.5 * h_, 0.0); }
+ Here is the caller graph for this function:

◆ tr2()

Time tr2 ( const Time  t) const
protected

Definition at line 114 of file parametrization.hpp.

114{ return t > h2_ ? t + h2_ : 2.0 * h2_; }

◆ tm2()

Time tm2 ( const Time  t) const
protected

Definition at line 116 of file parametrization.hpp.

116{ return t > h2_ ? t : h2_; }

◆ tl2()

Time tl2 ( const Time  t) const
protected

Definition at line 118 of file parametrization.hpp.

118{ return std::max(t - h2_, 0.0); }

Member Data Documentation

◆ h_

const Real h_
protected

step size for numerical differentiation

Definition at line 91 of file parametrization.hpp.

◆ h2_

const Real h2_
protected

Definition at line 91 of file parametrization.hpp.

◆ currency_

Currency currency_
private

Definition at line 100 of file parametrization.hpp.

◆ name_

std::string name_
private

Definition at line 101 of file parametrization.hpp.

◆ emptyTimes_

const Array emptyTimes_
private

Definition at line 102 of file parametrization.hpp.

◆ emptyParameter_

const QuantLib::ext::shared_ptr<Parameter> emptyParameter_
private

Definition at line 103 of file parametrization.hpp.