Piecewise Constant Helper2.
More...
#include <qle/models/piecewiseconstanthelper.hpp>
|
| PiecewiseConstantHelper2 (const Array &t, const QuantLib::ext::shared_ptr< PseudoParameter > &y) |
|
| PiecewiseConstantHelper2 (const Array &t, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >()) |
|
| PiecewiseConstantHelper2 (const std::vector< Date > &dates, const Handle< YieldTermStructure > &yts, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >()) |
|
const Array & | t () const |
|
const QuantLib::ext::shared_ptr< Parameter > | p () const |
|
void | update () const |
|
Real | y (const Time t) const |
|
Real | exp_m_int_y (const Time t) const |
| exp(int_0^t -y(s)) ds More...
|
|
Real | int_exp_m_int_y (const Time t) const |
| int_0^t exp(int_0^s -y(u) du) ds More...
|
|
Real | direct (const Real x) const |
|
Real | inverse (const Real y) const |
|
Piecewise Constant Helper2.
Definition at line 92 of file piecewiseconstanthelper.hpp.
◆ PiecewiseConstantHelper2() [1/3]
Definition at line 88 of file piecewiseconstanthelper.cpp.
const QuantLib::ext::shared_ptr< PseudoParameter > y_
const QuantLib::ext::shared_ptr< Parameter > p() const
◆ PiecewiseConstantHelper2() [2/3]
PiecewiseConstantHelper2 |
( |
const Array & |
t, |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint = QuantLib::ext::make_shared< QuantLib::NoConstraint >() |
|
) |
| |
◆ PiecewiseConstantHelper2() [3/3]
PiecewiseConstantHelper2 |
( |
const std::vector< Date > & |
dates, |
|
|
const Handle< YieldTermStructure > & |
yts, |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint = QuantLib::ext::make_shared< QuantLib::NoConstraint >() |
|
) |
| |
◆ t()
const Array & t |
( |
| ) |
const |
◆ p()
const QuantLib::ext::shared_ptr< Parameter > p |
( |
| ) |
const |
◆ update()
Definition at line 201 of file piecewiseconstanthelper.hpp.
201 {
202 Real
sum = 0.0, sum2 = 0.0;
203 b_.resize(
t_.size());
204 c_.resize(
t_.size());
205 for (Size i = 0; i <
t_.size(); ++i) {
206 Real t0 = (i == 0 ? 0.0 :
t_[i - 1]);
209 Real b2Tmp = (i == 0 ? 0.0 :
b_[i - 1]);
211 sum2 += (
t_[i] - t0) * std::exp(-b2Tmp);
212 } else {
213 sum2 += (std::exp(-b2Tmp) - std::exp(-b2Tmp -
direct(
y_->params()[i]) * (
t_[i] - t0))) /
215 }
217 }
218}
Real direct(const Real x) const
Real sum(const Cash &c, const Cash &d)
◆ y()
Real y |
( |
const Time |
t | ) |
const |
◆ exp_m_int_y()
Real exp_m_int_y |
( |
const Time |
t | ) |
const |
exp(int_0^t -y(s)) ds
Definition at line 300 of file piecewiseconstanthelper.hpp.
300 {
302 return 1.0;
303 Size i = std::upper_bound(
t_.begin(),
t_.end(),
t) -
t_.begin();
304 Real res = 0.0;
305 if (i >= 1)
306 res +=
b_[std::min(i - 1,
b_.size() - 1)];
307 Real a =
y_->params()[std::min(i,
y_->size() - 1)];
308 res += a * (
t - (i == 0 ? 0.0 :
t_[i - 1]));
309 return std::exp(-res);
310}
◆ int_exp_m_int_y()
Real int_exp_m_int_y |
( |
const Time |
t | ) |
const |
int_0^t exp(int_0^s -y(u) du) ds
Definition at line 312 of file piecewiseconstanthelper.hpp.
312 {
314 return 0.0;
315 Size i = std::upper_bound(
t_.begin(),
t_.end(),
t) -
t_.begin();
316 Real res = 0.0;
317 if (i >= 1)
318 res +=
c_[std::min(i - 1,
c_.size() - 1)];
319 Real a =
direct(
y_->params()[std::min(i,
y_->size() - 1)]);
320 Real t0 = (i == 0 ? 0.0 :
t_[i - 1]);
321 Real b2Tmp = (i == 0 ? 0.0 :
b_[i - 1]);
323 res += std::exp(-b2Tmp) * (
t - t0);
324 } else {
325 res += (std::exp(-b2Tmp) - std::exp(-b2Tmp - a * (
t - t0))) / a;
326 }
327 return res;
328}
◆ direct()
Real direct |
( |
const Real |
x | ) |
const |
◆ inverse()
Real inverse |
( |
const Real |
y | ) |
const |
◆ zeroCutoff_
◆ t_
◆ y_
◆ b_
◆ c_