QuantLib: RandomLM< derivedRandomLM, copulaPolicy, USNG > Class Template Reference

A free/open-source library for quantitative finance Reference manual - version 1.6

- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RandomLM< derivedRandomLM, copulaPolicy, USNG > Class Template Reference

`#include <ql/experimental/credit/randomdefaultlatentmodel.hpp>`

Inheritance diagram for RandomLM< derivedRandomLM, copulaPolicy, USNG >:
[legend]

## Protected Member Functions
| RandomLM (Size numFactors, Size numLMVars, const copulaPolicy &copula, Size nSims, BigNatural seed)
void | update ()
void | performCalculations () const
void | performSimulations () const
const std::vector< simEvent< derivedRandomLM< copulaPolicy, USNG > > > & | getSim (const Size iSim) const
Real | getEventRecovery (const simEvent< derivedRandomLM< copulaPolicy, USNG > > &evt) const
Statistics, DefaultLossModel interface.
virtual Probability | probAtLeastNEvents (Size n, const Date &d) const
virtual Disposable< std::vector< Probability > > | probsBeingNthEvent (Size n, const Date &d) const
virtual Real | defaultCorrelation (const Date &d, Size iName, Size jName) const
| Pearsons' default probability correlation.
virtual Real | expectedTrancheLoss (const Date &d) const
virtual std::pair< Real, Real > | expectedTrancheLossInterval (const Date &d, Probability confidencePerc) const
virtual Disposable< std::map< Real, Probability > > | lossDistribution (const Date &d) const
| Full loss distribution.
virtual Histogram | computeHistogram (const Date &d) const
virtual Real | expectedShortfall (const Date &d, Real percent) const
| Expected shortfall given a default loss percentile.
virtual Real | percentile (const Date &d, Real percentile) const
| Value at Risk given a default loss percentile.
virtual boost::tuples::tuple< Real, Real, Real > | percentileAndInterval (const Date &d, Real percentile) const
virtual Disposable< std::vector< Real > > | splitVaRLevel (const Date &date, Real loss) const
virtual Disposable< 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
virtual Probability | probOverLoss (const Date &d, Real lossFraction) const
virtual Disposable< std::vector< Real > > | splitESFLevel (const Date &d, Real loss) const
| Associated ESF fraction to each counterparty.
virtual Real | densityTrancheLoss (const Date &d, Real lossFraction) const
| Probability density of a given loss fraction of the basket notional.
virtual Real | expectedRecovery (const Date &, Size iName, const DefaultProbKey &) const

## Protected Attributes
const Size | numFactors_
const Size | numLMVars_
const Size | nSims_
std::vector< std::vector< simEvent< derivedRandomLM< copulaPolicy, USNG > > > > | simsBuffer_
copulaPolicy | copula_
boost::shared_ptr< copulaRNG_type > | copulasRng_
Protected Attributes inherited from LazyObject
bool | calculated_
bool | frozen_
Protected Attributes inherited from DefaultLossModel
RelinkableHandle< Basket > | basket_

## Static Protected Attributes
static const Size | maxHorizon_ = 4050

## Additional Inherited Members
Public Member Functions inherited from LazyObject
void | update ()
void | recalculate ()
void | freeze ()
void | unfreeze ()
Public Member Functions inherited from Observable
| Observable (const Observable &)
Observable & | operator= (const Observable &)
void | notifyObservers ()
Public Member Functions inherited from Observer
| Observer (const Observer &)
Observer & | operator= (const Observer &)
std::pair< std::set< boost::shared_ptr< Observable > >::iterator, bool > | registerWith (const boost::shared_ptr< Observable > &)
void | registerWithObservables (const boost::shared_ptr< Observer > &)
Size | unregisterWith (const boost::shared_ptr< Observable > &)
void | unregisterWithAll ()

## Detailed Description

### template<template< class, class > class derivedRandomLM, class copulaPolicy, class USNG = SobolRsg>
class QuantLib::RandomLM< derivedRandomLM, copulaPolicy, USNG >

Base class for latent model monte carlo simulation. Independent of the copula type and the generator. Generates the factors and variable samples and determines event threshold but it is not responsible for actual event specification; thats the derived classes responsibility according to what they model. Derived classes need mainly to implement nextSample (Worker::nextSample in the multithreaded version) to compute the simulation event generated, if any, from the latent variables sample. They also have the accompanying event trait to specify.

## Member Function Documentation

void update | ( |  | ) |
| protectedvirtual

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Implements Observer.

void performCalculations | ( |  | ) | const
| protectedvirtual

This method must implement any calculations which must be (re)done in order to calculate the desired results.

Implements LazyObject.

Probability probAtLeastNEvents | ( | Size | n,
|  | const Date & | d
| ) |  | const
| protectedvirtual

Returns the probaility of having a given or larger number of defaults in the basket portfolio at a given time.

Reimplemented from DefaultLossModel.

Disposable< std::vector< Probability > > probsBeingNthEvent | ( | Size | n,
|  | const Date & | d
| ) |  | const
| protectedvirtual

Order of results refers to the simulated (super)pool not the basket's pool. Notice that this statistic suffers from heavy dispersion. To see techniques to improve it (not implemented here) see: Joshi, M., D. Kainth. 2004. Rapid and accurate development of prices and Greeks for nth to default credit swaps in the Li model. Quantitative Finance, Vol. 4. Institute of Physics Publishing, London, UK, 266–275 and: Chen, Z., Glasserman, P. 'Fast pricing of basket default swaps' in Operations Research Vol. 56, No. 2, March–April 2008, pp. 286–303

Reimplemented from DefaultLossModel.

boost::tuples::tuple< Real, Real, Real > percentileAndInterval | ( | const Date & | d,
|  | Real | percentile
| ) |  | const
| protectedvirtual

Returns the VaR value for a given percentile and the 95 confidence interval of that value.

Disposable< std::vector< Real > > splitVaRLevel | ( | const Date & | date,
|  | Real | loss
| ) |  | const
| protectedvirtual

Distributes the total VaR amount along the portfolio counterparties.

Parameters

  loss | Loss amount (in loss units).

Reimplemented from DefaultLossModel.

Disposable< std::vector< std::vector< Real > > > splitVaRAndError | ( | const Date & | date,
|  | Real | loss,
|  | Probability | confInterval
| ) |  | const
| protectedvirtual

Distributes the total VaR amount along the portfolio counterparties. Provides confidence interval for split so that portfolio optimization can be performed outside those limits.

Parameters

  loss | Loss amount (in loss units).