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

Default probability term structure implied from a transition matrix. More...

#include <qle/termstructures/generatordefaulttermstructure.hpp>

+ Inheritance diagram for GeneratorDefaultProbabilityTermStructure:
+ Collaboration diagram for GeneratorDefaultProbabilityTermStructure:

Public Types

enum class  MatrixType { Transition , Generator }
 

Public Member Functions

 GeneratorDefaultProbabilityTermStructure (MatrixType matrixType, Matrix matrix, Size initialState, const Date &referenceDate, const Calendar &cal=NullCalendar(), const DayCounter &dc=Actual365Fixed())
 Constructor using a single (annual!) transition matrix or a generator matrix. More...
 
Date maxDate () const override
 
const Matrix & transitionMatrix () const
 return the underlying annualised transition matrix More...
 
const Matrix & generator () const
 

Protected Member Functions

Probability survivalProbabilityImpl (Time) const override
 

Private Attributes

Size initialState_
 
Matrix transitionMatrix_
 
Matrix generator_
 

Detailed Description

Default probability term structure implied from a transition matrix.

This class uses a transition or generator matrix to imply cumulative survival probabilities depending on initial state.

Definition at line 41 of file generatordefaulttermstructure.hpp.

Member Enumeration Documentation

◆ MatrixType

enum class MatrixType
strong

Constructor & Destructor Documentation

◆ GeneratorDefaultProbabilityTermStructure()

GeneratorDefaultProbabilityTermStructure ( MatrixType  matrixType,
Matrix  matrix,
Size  initialState,
const Date &  referenceDate,
const Calendar &  cal = NullCalendar(),
const DayCounter &  dc = Actual365Fixed() 
)

Constructor using a single (annual!) transition matrix or a generator matrix.

Definition at line 30 of file generatordefaulttermstructure.cpp.

35 : SurvivalProbabilityStructure(referenceDate, cal, dc), initialState_(initialState),
36 transitionMatrix_(matrixType == MatrixType::Transition ? matrix : Matrix()),
37 generator_(matrixType == MatrixType::Generator ? matrix : Matrix()) {
38
39 QL_REQUIRE(matrix.rows() == matrix.columns(), "input matrix is not square");
40
41 // compute/check the generator
42 if (matrixType == MatrixType::Transition) {
46 }
48}
void checkTransitionMatrix(const Matrix &t)
check if the matrix is a transition matrix, i.e. row sums are 1 and entries are non-negative
void checkGeneratorMatrix(const Matrix &g)
check if the matrix is a generator matirx, i.e. row sums are 0 and non-diagonal elements are non-nega...
Matrix generator(const Matrix &t, const Real horizon)
void sanitiseTransitionMatrix(Matrix &m)
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 48 of file generatordefaulttermstructure.hpp.

48{ return QuantLib::Date::maxDate(); }

◆ transitionMatrix()

const Matrix & transitionMatrix ( ) const

return the underlying annualised transition matrix

Definition at line 51 of file generatordefaulttermstructure.hpp.

51{ return transitionMatrix_; }

◆ generator()

const Matrix & generator ( ) const

Definition at line 52 of file generatordefaulttermstructure.hpp.

52{ return generator_; }

◆ survivalProbabilityImpl()

Probability survivalProbabilityImpl ( Time  t) const
overrideprotected

Definition at line 50 of file generatordefaulttermstructure.cpp.

50 {
51 QL_REQUIRE(t >= 0.0, "non-negative time required");
52 Matrix Q = QuantExt::Expm(generator_ * t);
53 QL_REQUIRE(initialState_ < Q.rows(),
54 "initial state " << initialState_ << " out of range [0," << Q.rows() - 1 << "]");
55 Size lastState = Q.columns() - 1;
56 return 1.0 - Q[initialState_][lastState];
57}
QuantLib::Matrix Expm(const QuantLib::Matrix &m)
+ Here is the call graph for this function:

Member Data Documentation

◆ initialState_

Size initialState_
private

Definition at line 58 of file generatordefaulttermstructure.hpp.

◆ transitionMatrix_

Matrix transitionMatrix_
private

Definition at line 59 of file generatordefaulttermstructure.hpp.

◆ generator_

Matrix generator_
private

Definition at line 60 of file generatordefaulttermstructure.hpp.