QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
randomdefaultmodel.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Roland Lichters
5 Copyright (C) 2009 Jose Aparicio
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_random_default_model_hpp
26#define quantlib_random_default_model_hpp
27
28#include <ql/math/randomnumbers/rngtraits.hpp>
29#include <ql/experimental/credit/pool.hpp>
30#include <ql/experimental/credit/onefactorcopula.hpp>
31#include <ql/experimental/credit/defaultprobabilitykey.hpp>
32
33namespace QuantLib {
34
36
37 class RandomDefaultModel : public Observer, public Observable {
38 public:
39 RandomDefaultModel(const ext::shared_ptr<Pool>& pool,
40 const std::vector<DefaultProbKey>& defaultKeys)
41 : pool_(pool), defaultKeys_(defaultKeys) {
42 // assuming none defaulted this is true.
43 QL_REQUIRE(defaultKeys.size() == pool->size(), "Incompatible pool and keys sizes.");
44 }
45 ~RandomDefaultModel() override = default;
46 void update() override { notifyObservers(); }
53 virtual void nextSequence(Real tmax = QL_MAX_REAL) = 0;
54 virtual void reset() = 0;
55 protected:
56 ext::shared_ptr<Pool> pool_;
57 std::vector<DefaultProbKey> defaultKeys_;
58 };
59
64 public:
65 GaussianRandomDefaultModel(const ext::shared_ptr<Pool>& pool,
66 const std::vector<DefaultProbKey>& defaultKeys,
67 const Handle<OneFactorCopula>& copula,
68 Real accuracy,
69 long seed);
70 void nextSequence(Real tmax = QL_MAX_REAL) override;
71 void reset() override;
72
73 private:
76 long seed_;
78 };
79
80}
81
82#endif
void nextSequence(Real tmax=QL_MAX_REAL) override
Shared handle to an observable.
Definition: handle.hpp:41
Inverse cumulative random sequence generator.
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
Base class for random default models.
ext::shared_ptr< Pool > pool_
std::vector< DefaultProbKey > defaultKeys_
RandomDefaultModel(const ext::shared_ptr< Pool > &pool, const std::vector< DefaultProbKey > &defaultKeys)
virtual void nextSequence(Real tmax=QL_MAX_REAL)=0
~RandomDefaultModel() override=default
#define QL_MAX_REAL
Definition: qldefines.hpp:176
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35