27 SquareRootAndersen::SquareRootAndersen(
Real meanLevel,
31 const std::vector<Real>& evolutionTimes,
41 numberSubSteps_(numberSubSteps),
42 dt_(evolutionTimes.size()*numberSubSteps),
43 eMinuskDt_(evolutionTimes.size()*numberSubSteps),
47 vPath_(evolutionTimes.size()*numberSubSteps+1),
54 for (
Size i=1; i < evolutionTimes.size(); ++i)
58 Real ekdt = std::exp(-
k_*dt);
59 QL_REQUIRE(dt >0.0,
"Steps must be of positive size.");
98 Real s = std::sqrt(s2);
102 Real psiinv = 1.0/psi;
103 Real b2 = 2.0*psiinv -1+std::sqrt(2*psiinv*(2*psiinv-1.0));
104 Real b = std::sqrt(b2);
110 Real p = (psi-1.0)/(psi+1.0);
120 vt = std::log((1.0-p)/(1.0-u))/
beta;
143 Real stepVariance =0.0;
150 return std::sqrt(stepVariance);
Cumulative normal distribution function.
Size numberStateVariables() const override
std::vector< Real > state_
void DoOneSubStep(Real &v, Real variate, Size j)
Size variatesPerStep() override
std::vector< Real > vPath_
Size numberSteps() override
std::vector< Real > eMinuskDt_
Real stepSd() const override
const std::vector< Real > & stateVariables() const override
Real nextstep(const std::vector< Real > &variates) override
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
std::size_t Size
size of a container
normal, cumulative and inverse cumulative distributions