1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004, 2005 StatPro Italia srl
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
20#include <ql/processes/eulerdiscretization.hpp>
21
22namespace QuantLib {
23
24 Array EulerDiscretization::drift(const StochasticProcess& process,
25 Time t0, const Array& x0,
26 Time dt) const {
27 return process.drift(t: t0, x: x0)*dt;
28 }
29
30 Real EulerDiscretization::drift(const StochasticProcess1D& process,
31 Time t0, Real x0, Time dt) const {
32 return process.drift(t: t0, x: x0)*dt;
33 }
34
35 Matrix EulerDiscretization::diffusion(const StochasticProcess& process,
36 Time t0,
37 const Array& x0,
38 Time dt) const {
39 return process.diffusion(t: t0, x: x0) * std::sqrt(x: dt);
40 }
41
42 Real EulerDiscretization::diffusion(const StochasticProcess1D& process,
43 Time t0, Real x0, Time dt) const {
44 return process.diffusion(t: t0, x: x0) * std::sqrt(x: dt);
45 }
46
47 Matrix EulerDiscretization::covariance(const StochasticProcess& process,
48 Time t0,
49 const Array& x0,
50 Time dt) const {
51 Matrix sigma = process.diffusion(t: t0, x: x0);
52 Matrix result = sigma*transpose(m: sigma)*dt;
53 return result;
54 }
55
56 Real EulerDiscretization::variance(const StochasticProcess1D& process,
57 Time t0, Real x0, Time dt) const {
58 Real sigma = process.diffusion(t: t0, x: x0);
59 return sigma*sigma*dt;
60 }
61
62}
63
64

source code of quantlib/ql/processes/eulerdiscretization.cpp

Morty Proxy This is a proxified and sanitized view of the page, visit original site.