Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Lgm1fPiecewiseLinearParametrization< TS > Class Template Reference

Lgm 1f Piecewise Linear Parametrization. More...

#include <qle/models/irlgm1fpiecewiselinearparametrization.hpp>

+ Inheritance diagram for Lgm1fPiecewiseLinearParametrization< TS >:
+ Collaboration diagram for Lgm1fPiecewiseLinearParametrization< TS >:

Public Member Functions

 Lgm1fPiecewiseLinearParametrization (const Currency &currency, const Handle< TS > &termStructure, const Array &alphaTimes, const Array &alpha, const Array &hTimes, const Array &h, const std::string &name=std::string(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &alphaConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &hConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
 Lgm1fPiecewiseLinearParametrization (const Currency &currency, const Handle< TS > &termStructure, const std::vector< Date > &alphaDates, const Array &alpha, const std::vector< Date > &hDates, const Array &h, const std::string &name=std::string(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &alphaConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &hConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
Real zeta (const Time t) const override
 
Real H (const Time t) const override
 
Real alpha (const Time t) const override
 
Real kappa (const Time t) const override
 
Real Hprime (const Time t) const override
 
Real Hprime2 (const Time t) const override
 
const Array & parameterTimes (const Size) const override
 
const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const override
 
void update () const override
 
- Public Member Functions inherited from Lgm1fParametrization< TS >
 Lgm1fParametrization (const Currency &currency, const Handle< TS > &termStructure, const std::string &name=std::string())
 
virtual Real zeta (const Time t) const =0
 
virtual Real H (const Time t) const =0
 
virtual Real alpha (const Time t) const
 
virtual Real kappa (const Time t) const
 
virtual Real Hprime (const Time t) const
 
virtual Real Hprime2 (const Time t) const
 
virtual Real hullWhiteSigma (const Time t) const
 
const Handle< TS > termStructure () const
 
Real zetan (const Size n, const Time t, const QuantLib::ext::shared_ptr< Integrator > &integrator)
 
Real & shift ()
 
Real & scaling ()
 
Size numberOfParameters () const override
 
void update () const override
 
- Public Member Functions inherited from Parametrization
 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

Real direct (const Size i, const Real x) const override
 
Real inverse (const Size j, const Real y) const override
 
- Protected Member Functions inherited from Parametrization
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
 

Private Member Functions

void initialize (const Array &alpha, const Array &h)
 
- Private Member Functions inherited from PiecewiseConstantHelper11
 PiecewiseConstantHelper11 (const Array &t1, const Array &t2, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint1=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint2=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
 PiecewiseConstantHelper11 (const std::vector< Date > &dates1, const std::vector< Date > &dates2, const Handle< YieldTermStructure > &yts, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint1=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint2=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
const PiecewiseConstantHelper1helper1 () const
 
const PiecewiseConstantHelper1helper2 () const
 

Additional Inherited Members

- Protected Attributes inherited from Lgm1fParametrization< TS >
Real shift_
 
Real scaling_
 
- Protected Attributes inherited from Parametrization
const Real h_
 
const Real h2_
 

Detailed Description

template<class TS>
class QuantExt::Lgm1fPiecewiseLinearParametrization< TS >

Lgm 1f Piecewise Linear Parametrization.

parametrization with piecewise linear H and zeta, w.r.t. zeta this is the same as piecewise constant alpha, w.r.t. H this is implemented with a new (helper) parameter h > 0, such that \(H(t) = \int_0^t h(s) ds\)

Warning:
this class is considered experimental, it is not tested well and might have conceptual issues (e.g. kappa is zero almost everywhere); you might rather want to rely on the piecewise constant parametrization

Definition at line 47 of file irlgm1fpiecewiselinearparametrization.hpp.

Constructor & Destructor Documentation

◆ Lgm1fPiecewiseLinearParametrization() [1/2]

Lgm1fPiecewiseLinearParametrization ( const Currency &  currency,
const Handle< TS > &  termStructure,
const Array &  alphaTimes,
const Array &  alpha,
const Array &  hTimes,
const Array &  h,
const std::string &  name = std::string(),
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  alphaConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>(),
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  hConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>() 
)

Definition at line 81 of file irlgm1fpiecewiselinearparametrization.hpp.

86 : Lgm1fParametrization<TS>(currency, termStructure, name),
87 PiecewiseConstantHelper11(alphaTimes, hTimes, alphaConstraint, hConstraint) {
88 initialize(alpha, h);
89}
const Handle< TS > termStructure() const
const std::string & name() const
virtual const Currency & currency() const
PiecewiseConstantHelper11(const Array &t1, const Array &t2, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint1=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint2=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
+ Here is the call graph for this function:

◆ Lgm1fPiecewiseLinearParametrization() [2/2]

Lgm1fPiecewiseLinearParametrization ( const Currency &  currency,
const Handle< TS > &  termStructure,
const std::vector< Date > &  alphaDates,
const Array &  alpha,
const std::vector< Date > &  hDates,
const Array &  h,
const std::string &  name = std::string(),
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  alphaConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>(),
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  hConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>() 
)

Definition at line 92 of file irlgm1fpiecewiselinearparametrization.hpp.

97 : Lgm1fParametrization<TS>(currency, termStructure, name),
98 PiecewiseConstantHelper11(alphaDates, hDates, termStructure, alphaConstraint, hConstraint) {
99 initialize(alpha, h);
100}
+ Here is the call graph for this function:

Member Function Documentation

◆ zeta()

Real zeta ( const Time  t) const
overridevirtual

zeta must satisfy zeta(0) = 0, zeta'(t) >= 0

Implements Lgm1fParametrization< TS >.

Definition at line 127 of file irlgm1fpiecewiselinearparametrization.hpp.

127 {
128 return helper1().int_y_sqr(t) / (this->scaling_ * this->scaling_);
129}
const PiecewiseConstantHelper1 & helper1() const
Real int_y_sqr(const Time t) const
int_0^t y^2(s) ds

◆ H()

Real H ( const Time  t) const
overridevirtual

H must be such that H' does not change its sign

Implements Lgm1fParametrization< TS >.

Definition at line 131 of file irlgm1fpiecewiselinearparametrization.hpp.

131 {
132 return this->scaling_ * helper2().int_y_sqr(t) + this->shift_;
133}
const PiecewiseConstantHelper1 & helper2() const

◆ alpha()

Real alpha ( const Time  t) const
overridevirtual

Reimplemented from Lgm1fParametrization< TS >.

Definition at line 135 of file irlgm1fpiecewiselinearparametrization.hpp.

135 {
136 return helper1().y(t) / this->scaling_;
137}
+ Here is the caller graph for this function:

◆ kappa()

Real kappa ( const Time  t) const
overridevirtual

Reimplemented from Lgm1fParametrization< TS >.

Definition at line 139 of file irlgm1fpiecewiselinearparametrization.hpp.

139 {
140 return 0.0; // almost everywhere
141}

◆ Hprime()

Real Hprime ( const Time  t) const
overridevirtual

Reimplemented from Lgm1fParametrization< TS >.

Definition at line 143 of file irlgm1fpiecewiselinearparametrization.hpp.

143 {
144 return this->scaling_ * helper2().y(t);
145}

◆ Hprime2()

Real Hprime2 ( const Time  t) const
overridevirtual

Reimplemented from Lgm1fParametrization< TS >.

Definition at line 147 of file irlgm1fpiecewiselinearparametrization.hpp.

147 {
148 return 0.0; // almost everywhere
149}

◆ parameterTimes()

const Array & parameterTimes ( const Size  Size) const
overridevirtual

the times associated to parameter i

Reimplemented from Parametrization.

Definition at line 157 of file irlgm1fpiecewiselinearparametrization.hpp.

157 {
158 QL_REQUIRE(i < 2, "parameter " << i << " does not exist, only have 0..1");
159 if (i == 0)
160 return helper1().t();
161 else
162 return helper2().t();
163 ;
164}

◆ parameter()

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

the parameter storing the raw parameter values

Reimplemented from Parametrization.

Definition at line 167 of file irlgm1fpiecewiselinearparametrization.hpp.

167 {
168 QL_REQUIRE(i < 2, "parameter " << i << " does not exist, only have 0..1");
169 if (i == 0)
170 return helper1().p();
171 else
172 return helper2().p();
173}
const QuantLib::ext::shared_ptr< Parameter > p() const

◆ update()

void update
overridevirtual

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

Reimplemented from Lgm1fParametrization< TS >.

Definition at line 151 of file irlgm1fpiecewiselinearparametrization.hpp.

+ Here is the call graph for this function:

◆ direct()

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

transformations between raw and actual parameters

Reimplemented from Parametrization.

Definition at line 119 of file irlgm1fpiecewiselinearparametrization.hpp.

119 {
120 return i == 0 ? helper1().direct(x) : helper2().direct(x);
121}

◆ inverse()

Real inverse ( const Size  j,
const Real  y 
) const
overrideprotectedvirtual

Reimplemented from Parametrization.

Definition at line 123 of file irlgm1fpiecewiselinearparametrization.hpp.

123 {
124 return i == 0 ? helper1().inverse(y) : helper2().inverse(y);
125}

◆ initialize()

void initialize ( const Array &  alpha,
const Array &  h 
)
private

Definition at line 102 of file irlgm1fpiecewiselinearparametrization.hpp.

102 {
103 QL_REQUIRE(helper1().t().size() + 1 == alpha.size(),
104 "alpha size (" << alpha.size() << ") inconsistent to times size (" << helper1().t().size() << ")");
105 QL_REQUIRE(helper2().t().size() + 1 == h.size(),
106 "h size (" << h.size() << ") inconsistent to times size (" << helper1().t().size() << ")");
107 // store raw parameter values
108 for (Size i = 0; i < helper1().p()->size(); ++i) {
109 helper1().p()->setParam(i, inverse(0, alpha[i]));
110 }
111 for (Size i = 0; i < helper2().p()->size(); ++i) {
112 helper2().p()->setParam(i, inverse(1, h[i]));
113 }
114 update();
115}
Real inverse(const Size j, const Real y) const override
+ Here is the call graph for this function:
+ Here is the caller graph for this function: