Skip to content

Commit 6c016db

Browse files
committed
QPR-11360 introduce better initial guess rdm
1 parent d10b7b8 commit 6c016db

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

ql/experimental/credit/randomdefaultmodel.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ namespace QuantLib {
7171
Real y = a * values[0] + sqrt(1-a*a) * values[j+1];
7272
Real p = CumulativeNormalDistribution()(y);
7373

74-
if (dts->defaultProbability(tmax) < p || dts->hazardRate(dts->referenceDate() + 1.0 * Days ,true) < QL_EPSILON)
74+
if (dts->defaultProbability(tmax) < p)
7575
pool_->setTime(name, tmax+1);
76-
else
77-
pool_->setTime(name, Brent().solve(Root(dts,p),accuracy_,0,1));
76+
else{
77+
int guess = 0;
78+
while(dts->defaultProbability(guess) < p && guess < tmax)
79+
guess++;
80+
pool_->setTime(name, Brent().solve(Root(dts,p),accuracy_,guess,1));
81+
}
7882
}
7983
}
8084

0 commit comments

Comments
 (0)