QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
RandomDefaultLM< copulaPolicy, USNG > Class Template Reference

#include <randomdefaultlatentmodel.hpp>

+ Inheritance diagram for RandomDefaultLM< copulaPolicy, USNG >:
+ Collaboration diagram for RandomDefaultLM< copulaPolicy, USNG >:

Public Member Functions

 RandomDefaultLM (const ext::shared_ptr< DefaultLatentModel< copulaPolicy > > &model, const std::vector< Real > &recoveries=std::vector< Real >(), Size nSims=0, Real accuracy=1.e-6, BigNatural seed=2863311530UL)
 
 RandomDefaultLM (const ext::shared_ptr< ConstantLossLatentmodel< copulaPolicy > > &model, Size nSims=0, Real accuracy=1.e-6, BigNatural seed=2863311530UL)
 
- Public Member Functions inherited from RandomLM< derivedRandomLM, copulaPolicy, USNG >
 ~RandomLM () override=default
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
void update () override
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 

Protected Member Functions

void nextSample (const std::vector< Real > &values) const
 
void initDates () const
 
Real getEventRecovery (const defaultSimEvent &evt) const
 
Real expectedRecovery (const Date &, Size iName, const DefaultProbKey &) const override
 
Real latentVarValue (const std::vector< Real > &factorsSample, Size iVar) const
 
Size basketSize () const
 
- Protected Member Functions inherited from RandomLM< derivedRandomLM, copulaPolicy, USNG >
 RandomLM (Size numFactors, Size numLMVars, copulaPolicy copula, Size nSims, BigNatural seed)
 
void update () override
 
void performCalculations () const override
 
void performSimulations () const
 
const std::vector< simEvent< derivedRandomLM< copulaPolicy, USNG > > > & getSim (const Size iSim) const
 
Real getEventRecovery (const simEvent< derivedRandomLM< copulaPolicy, USNG > > &evt) const
 
Probability probAtLeastNEvents (Size n, const Date &d) const override
 
std::vector< ProbabilityprobsBeingNthEvent (Size n, const Date &d) const override
 
Real defaultCorrelation (const Date &d, Size iName, Size jName) const override
 Pearsons' default probability correlation. More...
 
Real expectedTrancheLoss (const Date &d) const override
 
virtual std::pair< Real, RealexpectedTrancheLossInterval (const Date &d, Probability confidencePerc) const
 
std::map< Real, ProbabilitylossDistribution (const Date &d) const override
 Full loss distribution. More...
 
virtual Histogram computeHistogram (const Date &d) const
 
Real expectedShortfall (const Date &d, Real percent) const override
 Expected shortfall given a default loss percentile. More...
 
Real percentile (const Date &d, Real percentile) const override
 Value at Risk given a default loss percentile. More...
 
virtual ext::tuple< Real, Real, RealpercentileAndInterval (const Date &d, Real percentile) const
 
std::vector< RealsplitVaRLevel (const Date &date, Real loss) const override
 
virtual std::vector< std::vector< Real > > splitVaRAndError (const Date &date, Real loss, Probability confInterval) const
 
- Protected Member Functions inherited from LazyObject
virtual void calculate () const
 
- Protected Member Functions inherited from DefaultLossModel
 DefaultLossModel ()=default
 
virtual Probability probOverLoss (const Date &d, Real lossFraction) const
 
virtual std::vector< RealsplitESFLevel (const Date &d, Real loss) const
 Associated ESF fraction to each counterparty. More...
 
virtual Real densityTrancheLoss (const Date &d, Real lossFraction) const
 Probability density of a given loss fraction of the basket notional. More...
 

Private Types

typedef simEvent< RandomDefaultLMdefaultSimEvent
 

Private Member Functions

void resetModel () override
 Concrete models do now any updates/inits they need on basket reset. More...
 

Private Attributes

const ext::shared_ptr< DefaultLatentModel< copulaPolicy > > model_
 
const std::vector< Realrecoveries_
 
Real accuracy_
 
std::vector< ProbabilityhorizonDefaultPs_
 

Friends

class RandomLM< ::QuantLib::RandomDefaultLM, copulaPolicy, USNG >
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Attributes inherited from RandomLM< derivedRandomLM, copulaPolicy, USNG >
const Size numFactors_
 
const Size numLMVars_
 
const Size nSims_
 
std::vector< std::vector< simEvent< derivedRandomLM< copulaPolicy, USNG > > > > simsBuffer_
 
copulaPolicy copula_
 
ext::shared_ptr< copulaRNG_typecopulasRng_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 
- Protected Attributes inherited from DefaultLossModel
RelinkableHandle< Basketbasket_
 
- Static Protected Attributes inherited from RandomLM< derivedRandomLM, copulaPolicy, USNG >
static const Size maxHorizon_ = 4050
 

Detailed Description

template<class copulaPolicy, class USNG = SobolRsg>
class QuantLib::RandomDefaultLM< copulaPolicy, USNG >

Random default with deterministic recovery event type.

Stores sims results in a bitfield buffer for lean memory storage. Although strictly speaking this is not guaranteed by the compiler it amounts to reducing the memory storage by half. Some computations, like conditional statistics, precise that all sims results be available.

Default only latent model simulation with trivially fixed recovery amounts.

Examples
BasketLosses.cpp.

Definition at line 806 of file randomdefaultlatentmodel.hpp.

Member Typedef Documentation

◆ defaultSimEvent

Definition at line 809 of file randomdefaultlatentmodel.hpp.

Constructor & Destructor Documentation

◆ RandomDefaultLM() [1/2]

RandomDefaultLM ( const ext::shared_ptr< DefaultLatentModel< copulaPolicy > > &  model,
const std::vector< Real > &  recoveries = std::vector<Real>(),
Size  nSims = 0,
Real  accuracy = 1.e-6,
BigNatural  seed = 2863311530UL 
)
explicit

Definition at line 818 of file randomdefaultlatentmodel.hpp.

+ Here is the call graph for this function:

◆ RandomDefaultLM() [2/2]

RandomDefaultLM ( const ext::shared_ptr< ConstantLossLatentmodel< copulaPolicy > > &  model,
Size  nSims = 0,
Real  accuracy = 1.e-6,
BigNatural  seed = 2863311530UL 
)
explicit

Definition at line 832 of file randomdefaultlatentmodel.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ nextSample()

void nextSample ( const std::vector< Real > &  values) const
protected

Definition at line 920 of file randomdefaultlatentmodel.hpp.

+ Here is the call graph for this function:

◆ initDates()

void initDates ( ) const
protected

Definition at line 863 of file randomdefaultlatentmodel.hpp.

+ Here is the call graph for this function:

◆ getEventRecovery()

Real getEventRecovery ( const defaultSimEvent evt) const
protected

Definition at line 877 of file randomdefaultlatentmodel.hpp.

◆ expectedRecovery()

Real expectedRecovery ( const Date ,
Size  iName,
const DefaultProbKey  
) const
overrideprotectedvirtual

Expected RR for name conditinal to default by that date.

Reimplemented from DefaultLossModel.

Definition at line 880 of file randomdefaultlatentmodel.hpp.

◆ latentVarValue()

Real latentVarValue ( const std::vector< Real > &  factorsSample,
Size  iVar 
) const
protected

Definition at line 885 of file randomdefaultlatentmodel.hpp.

◆ basketSize()

Size basketSize ( ) const
protected

Definition at line 891 of file randomdefaultlatentmodel.hpp.

◆ resetModel()

void resetModel ( )
overrideprivatevirtual

Concrete models do now any updates/inits they need on basket reset.

Implements DefaultLossModel.

Definition at line 893 of file randomdefaultlatentmodel.hpp.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ RandomLM< ::QuantLib::RandomDefaultLM, copulaPolicy, USNG >

friend class RandomLM< ::QuantLib::RandomDefaultLM, copulaPolicy, USNG >
friend

Definition at line 832 of file randomdefaultlatentmodel.hpp.

Member Data Documentation

◆ model_

const ext::shared_ptr<DefaultLatentModel<copulaPolicy> > model_
private

Definition at line 812 of file randomdefaultlatentmodel.hpp.

◆ recoveries_

const std::vector<Real> recoveries_
private

Definition at line 813 of file randomdefaultlatentmodel.hpp.

◆ accuracy_

Real accuracy_
private

Definition at line 815 of file randomdefaultlatentmodel.hpp.

◆ horizonDefaultPs_

std::vector<Probability> horizonDefaultPs_
mutableprivate

Definition at line 912 of file randomdefaultlatentmodel.hpp.