32 std::vector<ext::shared_ptr<StochasticProcess> > l,
Size factors)
33 : l_(
std::move(l)), factors_(factors) {
35 for (
const auto& iter :
l_) {
42 for (
const auto& iter :
l_) {
44 size_ += iter->size();
80 for (
auto iter =
l_.begin(); iter !=
l_.end(); ++iter) {
81 const Array& pInitValues = (*iter)->initialValues();
83 std::copy(pInitValues.
begin(), pInitValues.
end(),
92 const Array& x)
const {
95 for (
Size i=0; i <
l_.size(); ++i) {
99 std::copy(pDrift.
begin(), pDrift.
end(),
111 for (
Size i=0; i <
l_.size(); ++i) {
113 const Array& pExpectation =
l_[i]->expectation(t0,
slice(x0,i), dt);
115 std::copy(pExpectation.
begin(), pExpectation.
end(),
125 const Time dt = 0.001;
137 for (
Size j=0; j <
l_.size(); ++j) {
142 for (
Size i=0; i < pCov.
rows(); ++i) {
154 crossModelCovar[i][j] *= volatility[i]*volatility[j];
158 retVal += crossModelCovar;
172 const Array& dx)
const {
175 for (
Size i=0; i <
l_.size(); ++i) {
178 std::copy(pApply.
begin(), pApply.
end(),
194 for (
Size i=0; i < cov.
rows(); ++i) {
196 const Real div = sqrtDiag[i]*sqrtDiag[j];
198 cov[i][j] = cov[j][i] = ( div > 0) ?
Real(cov[i][j]/div) : 0.0;
204 for (
Size j = 0; j <
l_.size(); ++j) {
210 for (
Size i=0; i < stdDev.
rows(); ++i) {
218 [=](
Real x) ->
Real { return x / vol; });
230 for (
Size i=0; i <
s.size(); ++i) {
238 for (
Size i=0; i < stdDev.
rows(); ++i) {
251 for (
Size i=0; i < cov.
rows(); ++i) {
275 for (
auto iter =
l_.begin(); iter !=
l_.end(); ++iter) {
276 const Size i = iter -
l_.begin();
278 Array dz((*iter)->factors());
282 Array x((*iter)->size());
286 const Array r = (*iter)->evolve(t0, x, dt, dz);
290 return this->
postEvolve(t0, x0, dt, dv, retVal);
293 const std::vector<ext::shared_ptr<StochasticProcess> > &
301 return l_[0]->time(date);
1-D array used in linear algebra.
const_iterator end() const
const_iterator begin() const
std::vector< ext::shared_ptr< StochasticProcess > > l_
Array slice(const Array &x, Size i) const
virtual Matrix crossModelCorrelation(Time t0, const Array &x0) const =0
Array drift(Time t, const Array &x) const override
returns the drift part of the equation, i.e.,
Size size() const override
returns the number of dimensions of the stochastic process
Array evolve(Time t0, const Array &x0, Time dt, const Array &dw) const override
Matrix diffusion(Time t, const Array &x) const override
returns the diffusion part of the equation, i.e.
Time time(const Date &date) const override
Matrix stdDeviation(Time t0, const Array &x0, Time dt) const override
std::map< CachingKey, Matrix > correlationCache_
virtual Array postEvolve(Time t0, const Array &x0, Time dt, const Array &dw, const Array &y0) const =0
std::vector< Size > vfactors_
virtual void preEvolve(Time t0, const Array &x0, Time dt, const Array &dw) const =0
virtual bool correlationIsStateDependent() const =0
Size factors() const override
returns the number of independent factors of the process
std::vector< Size > vsize_
Matrix covariance(Time t0, const Array &x0, Time dt) const override
Array expectation(Time t0, const Array &x0, Time dt) const override
Array initialValues() const override
returns the initial values of the state variables
Array apply(const Array &x0, const Array &dx) const override
JointStochasticProcess(std::vector< ext::shared_ptr< StochasticProcess > > l, Size factors=Null< Size >())
const std::vector< ext::shared_ptr< StochasticProcess > > & constituents() const
Matrix used in linear algebra.
const_row_iterator row_begin(Size i) const
const_row_iterator row_end(Size i) const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Singular value decomposition.
const Array & singularValues() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
multi model process for hybrid products
Matrix pseudoSqrt(const Matrix &matrix, SalvagingAlgorithm::Type sa)
Matrix rankReducedSqrt(const Matrix &matrix, Size maxRank, Real componentRetainedPercentage, SalvagingAlgorithm::Type sa)
Array Sqrt(const Array &v)
Matrix transpose(const Matrix &m)
ext::shared_ptr< YieldTermStructure > r
pseudo square root of a real symmetric matrix
singular value decomposition