Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LossModelConditionalDist< CopulaPolicy > Class Template Reference

#include <qle/models/poollossmodel.hpp>

+ Collaboration diagram for LossModelConditionalDist< CopulaPolicy >:

Classes

struct  keyCmp
 

Public Member Functions

 LossModelConditionalDist (const QuantLib::ext::shared_ptr< ExtendedConstantLossLatentModel< CopulaPolicy > > &copula, const QuantLib::ext::shared_ptr< QuantLib::LossDist > &bucketing, const std::vector< QuantLib::Real > &marginalDps, const std::vector< QuantLib::Real > &lgds)
 
QuantLib::Real conditionalDensity (QuantLib::Real factor, QuantLib::Size bucket)
 
QuantLib::Real conditionalAverage (QuantLib::Real factor, QuantLib::Size bucket)
 

Private Member Functions

std::pair< Distribution, QuantLib::Real > distribution (QuantLib::Real factor)
 

Private Attributes

const QuantLib::ext::shared_ptr< ExtendedConstantLossLatentModel< CopulaPolicy > > copula_
 
QuantLib::ext::shared_ptr< QuantLib::LossDist > bucketing_
 
std::vector< QuantLib::Real > inverseMarginalDps_
 
std::vector< QuantLib::Real > lgds_
 
std::map< QuantLib::Real, std::pair< Distribution, QuantLib::Real >, keyCmpconditionalDists_
 

Detailed Description

template<class CopulaPolicy>
class QuantExt::LossModelConditionalDist< CopulaPolicy >

Definition at line 110 of file poollossmodel.hpp.

Constructor & Destructor Documentation

◆ LossModelConditionalDist()

LossModelConditionalDist ( const QuantLib::ext::shared_ptr< ExtendedConstantLossLatentModel< CopulaPolicy > > &  copula,
const QuantLib::ext::shared_ptr< QuantLib::LossDist > &  bucketing,
const std::vector< QuantLib::Real > &  marginalDps,
const std::vector< QuantLib::Real > &  lgds 
)

Definition at line 541 of file poollossmodel.hpp.

546 : copula_(copula), bucketing_(bucketing),
547 inverseMarginalDps_(marginalDps.size()), lgds_(lgds) {
548
549 for (Size i = 0; i < marginalDps.size(); i++) {
550 inverseMarginalDps_[i] = copula_->inverseCumulativeY(marginalDps[i], i);
551 }
552}
std::vector< QuantLib::Real > lgds_
const QuantLib::ext::shared_ptr< ExtendedConstantLossLatentModel< CopulaPolicy > > copula_
QuantLib::ext::shared_ptr< QuantLib::LossDist > bucketing_
std::vector< QuantLib::Real > inverseMarginalDps_

Member Function Documentation

◆ conditionalDensity()

QuantLib::Real conditionalDensity ( QuantLib::Real  factor,
QuantLib::Size  bucket 
)

Definition at line 555 of file poollossmodel.hpp.

556 {
557 auto p = distribution(factor);
558 return p.first.density(bucket) * p.second;
559}
std::pair< Distribution, QuantLib::Real > distribution(QuantLib::Real factor)

◆ conditionalAverage()

QuantLib::Real conditionalAverage ( QuantLib::Real  factor,
QuantLib::Size  bucket 
)

Definition at line 562 of file poollossmodel.hpp.

563 {
564 auto p = distribution(factor);
565 return p.first.average(bucket) * p.second;
566}

◆ distribution()

std::pair< Distribution, QuantLib::Real > distribution ( QuantLib::Real  factor)
private

Definition at line 569 of file poollossmodel.hpp.

569 {
570
571 auto it = conditionalDists_.find(factor);
572 if (it != conditionalDists_.end())
573 return it->second;
574
575 // If we do not already have the distribution for the given factor, we create it.
576 // Vector of default probabilities conditional on the common market factor M: P(\tau_i < t | M = m)
577 std::vector<QuantLib::Real> cps(inverseMarginalDps_.size());
578 std::vector<QuantLib::Real> vFactor{ factor };
579 for (Size i = 0; i < cps.size(); i++) {
580 cps[i] = copula_->conditionalDefaultProbabilityInvP(inverseMarginalDps_[i], i, vFactor);
581 }
582
583 it = conditionalDists_.emplace(factor, std::make_pair((*bucketing_)(lgds_, cps), copula_->density(vFactor))).first;
584 return it->second;
585}
std::map< QuantLib::Real, std::pair< Distribution, QuantLib::Real >, keyCmp > conditionalDists_

Member Data Documentation

◆ copula_

const QuantLib::ext::shared_ptr<ExtendedConstantLossLatentModel<CopulaPolicy> > copula_
private

Definition at line 121 of file poollossmodel.hpp.

◆ bucketing_

QuantLib::ext::shared_ptr<QuantLib::LossDist> bucketing_
private

Definition at line 122 of file poollossmodel.hpp.

◆ inverseMarginalDps_

std::vector<QuantLib::Real> inverseMarginalDps_
private

Definition at line 123 of file poollossmodel.hpp.

◆ lgds_

std::vector<QuantLib::Real> lgds_
private

Definition at line 124 of file poollossmodel.hpp.

◆ conditionalDists_

std::map<QuantLib::Real, std::pair<Distribution, QuantLib::Real>, keyCmp> conditionalDists_
private

Definition at line 135 of file poollossmodel.hpp.