QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
klugeextouprocess.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2011 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#include <utility>
25
26namespace QuantLib {
27
29 Real rho,
30 ext::shared_ptr<ExtOUWithJumpsProcess> klugeProcess,
31 ext::shared_ptr<ExtendedOrnsteinUhlenbeckProcess> ouProcess)
32 : rho_(rho), sqrtMRho_(std::sqrt(1 - rho * rho)), klugeProcess_(std::move(klugeProcess)),
33 ouProcess_(std::move(ouProcess)) {
34 QL_REQUIRE(klugeProcess_, "null Kluge process");
35 QL_REQUIRE(ouProcess_, "null Ornstein-Uhlenbeck process");
36 }
37
39 return klugeProcess_->size() + 1;
40 }
41
43 return klugeProcess_->factors() + 1;
44 }
45
47 Array retVal(size());
48 const Array x0 = klugeProcess_->initialValues();
49 std::copy(x0.begin(), x0.end(), retVal.begin());
50 retVal.back() = ouProcess_->x0();
51
52 return retVal;
53 }
54
56 Array retVal(size());
57 Array mu = klugeProcess_->drift(t, x);
58 std::copy(mu.begin(), mu.end(), retVal.begin());
59 retVal.back() = ouProcess_->drift(t, x.back());
60
61 return retVal;
62 }
63
65 Matrix retVal(size(), factors(), 0.0);
66
67 Volatility vol = ouProcess_->diffusion(t, x.back());
68
69 retVal[0][0] = klugeProcess_->diffusion(t, x)[0][0];
70 retVal[size()][0] = rho_*vol;
71 retVal[size()][factors()] = sqrtMRho_*vol;
72
73 return retVal;
74 }
75
77 Time dt, const Array& dw) const{
78 Array retVal(size());
79
80 Array ev = klugeProcess_->evolve(t0, x0, dt, dw);
81 std::copy(ev.begin(), ev.end(), retVal.begin());
82
83 const Real dz = dw.back()*sqrtMRho_ + dw.front()*rho_;
84 retVal.back() = ouProcess_->evolve(t0, x0.back(), dt, dz);
85
86 return retVal;
87 }
88
89 ext::shared_ptr<ExtOUWithJumpsProcess>
91 return klugeProcess_;
92 }
93 ext::shared_ptr<ExtendedOrnsteinUhlenbeckProcess>
95 return ouProcess_;
96 }
97
99 return rho_;
100 }
101
102}
103
1-D array used in linear algebra.
Definition: array.hpp:52
const_iterator end() const
Definition: array.hpp:511
Real back() const
Definition: array.hpp:458
Real front() const
Definition: array.hpp:451
const_iterator begin() const
Definition: array.hpp:503
const ext::shared_ptr< ExtendedOrnsteinUhlenbeckProcess > ouProcess_
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
KlugeExtOUProcess(Real rho, ext::shared_ptr< ExtOUWithJumpsProcess > kluge, ext::shared_ptr< ExtendedOrnsteinUhlenbeckProcess > extOU)
Matrix diffusion(Time t, const Array &x) const override
returns the diffusion part of the equation, i.e.
Size factors() const override
returns the number of independent factors of the process
Array initialValues() const override
returns the initial values of the state variables
const ext::shared_ptr< ExtOUWithJumpsProcess > klugeProcess_
ext::shared_ptr< ExtOUWithJumpsProcess > getKlugeProcess() const
ext::shared_ptr< ExtendedOrnsteinUhlenbeckProcess > getExtOUProcess() const
Matrix used in linear algebra.
Definition: matrix.hpp:41
const DefaultType & t
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
extended Ornstein-Uhlenbeck process
Ornstein Uhlenbeck process plus exp jumps (Kluge Model)
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
std::size_t Size
size of a container
Definition: types.hpp:58
Real rho
joint Kluge process an d Ornstein Uhlenbeck process
Definition: any.hpp:35
STL namespace.
Interest-rate term structure.