35 Root(Handle<DefaultProbabilityTermStructure> dts,
Real pd)
38 QL_REQUIRE(
t >= 0.0,
"GaussianRandomDefaultModel: internal error, t < 0 ("
39 <<
t <<
") during root searching.");
40 return dts_->defaultProbability(
t,
true) -
pd_;
43 const Handle<DefaultProbabilityTermStructure>
dts_;
50 const ext::shared_ptr<Pool>& pool,
51 const std::vector<DefaultProbKey>& defaultKeys,
55 :
RandomDefaultModel(pool, defaultKeys), copula_(copula), accuracy_(accuracy), seed_(seed),
56 rsg_(
PseudoRandom::make_sequence_generator(pool->size() + 1, seed)) {
68 for (
Size j = 0; j <
pool_->size(); j++) {
69 const string name =
pool_->names()[j];
73 Real y = a * values[0] + sqrt(1-a*a) * values[j+1];
76 if (dts->defaultProbability(tmax) < p)
77 pool_->setTime(name, tmax + 1);
Cumulative normal distribution function.
GaussianRandomDefaultModel(const ext::shared_ptr< Pool > &pool, const std::vector< DefaultProbKey > &defaultKeys, const Handle< OneFactorCopula > &copula, Real accuracy, long seed)
PseudoRandom::rsg_type rsg_
Handle< OneFactorCopula > copula_
void nextSequence(Real tmax=QL_MAX_REAL) override
Shared handle to an observable.
const sample_type & nextSequence() const
returns next sample from the inverse cumulative distribution
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Base class for random default models.
ext::shared_ptr< Pool > pool_
std::vector< DefaultProbKey > defaultKeys_
void setLowerBound(Real lowerBound)
sets the lower bound for the function domain
Real solve(const F &f, Real accuracy, Real guess, Real step) const
void setUpperBound(Real upperBound)
sets the upper bound for the function domain
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
const Handle< DefaultProbabilityTermStructure > dts_
Random default-time scenarios for a pool of credit names.
static rsg_type make_sequence_generator(Size dimension, BigNatural seed)