39 y_[2] = std::exp(x[2]);
40 y_[3] = std::exp(x[3]);
41 y_[0] = std::exp(x[0]) -
y_[3];
48 y_[2] = std::log(x[2]);
49 y_[3] = std::log(x[3]);
50 y_[0] = std::log(x[0] + x[3]);
57 const std::vector<Real>& blackVols,
68 ext::shared_ptr<OptimizationMethod> optMethod)
78 "mismatch between number of times (" <<
t.size() <<
79 ") and blackVols (" << blackVols.size() <<
")");
86 bool useCostFunctionsJacobian =
false;
87 optMethod_ = ext::shared_ptr<OptimizationMethod>(
new
91 Size maxIterations = 10000;
92 Size maxStationaryStateIterations = 1000;
93 Real rootEpsilon = 1.0e-8;
94 Real functionEpsilon = 0.3e-4;
95 Real gradientNormEpsilon = 0.3e-4;
96 endCriteria_ = ext::make_shared<EndCriteria>(maxIterations, maxStationaryStateIterations,
97 rootEpsilon, functionEpsilon, gradientNormEpsilon);
103 Real weightsSum = 0.0;
134 std::vector<bool> parameterAreFixed(4);
143 inversedTransformatedGuess, parameterAreFixed);
146 (projectedAbcdCostFunction.
project(inversedTransformatedGuess));
149 Problem problem(projectedAbcdCostFunction, constraint, projectedGuess);
152 Array transfResult(projectedAbcdCostFunction.
include(projectedResult));
169 const std::vector<Real>& blackVols)
const {
171 "mismatch between number of times (" <<
t.size() <<
172 ") and blackVols (" << blackVols.size() <<
")");
173 std::vector<Real>
k(
t.size());
174 for (
Size i=0; i<
t.size() ; i++) {
187 return std::sqrt(
n*squaredError/(
n-1));
Abcd interpolation interpolation between discrete points.
ext::shared_ptr< EndCriteria > endCriteria_
std::vector< Real > blackVols_
EndCriteria::Type endCriteria() const
AbcdCalibration()=default
ext::shared_ptr< ParametersTransformation > transformation_
std::vector< Real > k(const std::vector< Real > &t, const std::vector< Real > &blackVols) const
adjustment factors needed to match Black vols
std::vector< Real > weights_
std::vector< Real > times_
Parameters.
EndCriteria::Type abcdEndCriteria_
ext::shared_ptr< OptimizationMethod > optMethod_
static void validate(Real a, Real b, Real c, Real d)
1-D array used in linear algebra.
Cumulative normal distribution function.
Real derivative(Real x) const
Criteria to end optimization process:
Levenberg-Marquardt optimization method.
Constrained optimization problem.
const Array & currentValue() const
current value of the local minimum
Parameterized cost function.
virtual Array include(const Array &projectedParameters) const
returns whole set of parameters corresponding to the set
virtual Array project(const Array ¶meters) const
returns the subset of free parameters corresponding
Abstract constraint class.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
Levenberg-Marquardt optimization method.
Abstract optimization method class.
Real abcdBlackVolatility(Time u, Real a, Real b, Real c, Real d)
normal, cumulative and inverse cumulative distributions