31 if (p < 1e-10)
return 0;
39 "conditional probability " << res <<
"out of range");
46 const vector<Real>& prob,
50 vector<Real> p (prob.size(), 0);
51 for (
Size i = 0; i < p.size(); i++)
61 QL_REQUIRE(!
y_.empty(),
"cumulative Y not tabulated yet");
67 for (
Size i = 0; i <
y_.size(); i++) {
82 QL_REQUIRE(!
y_.empty(),
"cumulative Y not tabulated yet");
103 Real norm = 0, mean = 0, var = 0;
110 QL_REQUIRE (fabs (norm - 1.0) < tolerance,
"norm out of tolerance range");
111 QL_REQUIRE (fabs (mean) < tolerance,
"mean out of tolerance range");
112 QL_REQUIRE (fabs (var - 1.0) < tolerance,
"variance out of tolerance range");
121 for (
Size i = 1; i < zSteps; i++) {
122 Real z1 = zMin + (zMax - zMin) / zSteps * (i - 1);
123 Real z2 = zMin + (zMax - zMin) / zSteps * i;
124 Real z = (z1 + z2) / 2;
127 mean += z * densitydz;
128 var += pow (z, 2) * densitydz;
131 QL_REQUIRE (fabs (norm - 1.0) < tolerance,
"norm out of tolerance range");
132 QL_REQUIRE (fabs (mean) < tolerance,
"mean out of tolerance range");
133 QL_REQUIRE (fabs (var - 1.0) < tolerance,
"variance out of tolerance range");
142 for (
Size i = 1; i < ySteps; i++) {
143 Real y1 = yMin + (yMax - yMin) / ySteps * (i - 1);
144 Real y2 = yMin + (yMax - yMin) / ySteps * i;
145 Real y = (y1 + y2) / 2;
148 mean +=
y * densitydy;
149 var +=
y *
y * densitydy;
152 QL_REQUIRE (fabs (norm - 1.0) < tolerance,
"norm out of tolerance range");
153 QL_REQUIRE (fabs (mean) < tolerance,
"mean out of tolerance range");
154 QL_REQUIRE (fabs (var - 1.0) < tolerance,
"variance out of tolerance range");
virtual void calculate() const
Real conditionalProbability(Real prob, Real m) const
Conditional probability.
Handle< Quote > correlation_
virtual Real cumulativeZ(Real z) const =0
Cumulative distribution of Z.
Real densitydm(Size i) const
std::vector< Real > cumulativeY_
virtual Real inverseCumulativeY(Real p) const
Inverse cumulative distribution of Y.
int checkMoments(Real tolerance) const
virtual Real cumulativeY(Real y) const
Cumulative distribution of Y.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
One-factor copula base class.