Posted by
Penschke, Walter on
URL: http://quantlib.414.s1.nabble.com/Question-on-PathGenerator-tp3287p3301.html
I'd like to add the formulas for the drift and diffusion implemented in
GeometricBrownianMotionProcess, because the source files cannot be retrieved
from the mailing list archive:
drift(t,x) = mue * x
diffusion(t,x) = sigma * x
Calls to the methods expectation() and variance()
are delegated to the sub-class StochasticProcess.
wpe
-----Original Message-----
From:
[hidden email]
[mailto:
[hidden email]]On Behalf Of
Penschke, Walter
Sent: Wednesday, September 01, 2004 5:57 PM
To:
[hidden email]
Subject: [Quantlib-users] Question on PathGenerator
Hi,
I am currently investigating quantlib's MonteCarlo package.
I tried to simulate a geometric brownian motion process, which I did define
in my own class GeometricBrownianMotionProcess. Basically this class is
derived from StochasticProcess and defines the methods drift and diffusion.
Here my source code:
<<GeometricBrownianMotionProcess.cpp>>
<<GeometricBrownianMotionProcess.hpp>>
The stochastic differential equation of this process is:
dS = mue * S * dt + sigma * S * dz
The problem now is that class PathGenerator from Quantlib (defined in
pathgenerator.hpp) does not produce proper paths for this process. Having
had a look at the next() method of PathGenerator (brownianBridge_ == false)
I realised that the drift and the diffusion arrays in the returned Path are
computed correctly in principal. However the asset_ variable, which tracks
the evolvement of the process, in my case S, within this method is adjusted
as follows per step:
asset_ *= QL_EXP(next_.value[i])
This is correct if the Path variable (next_) is modelling a process defined
on dS/S, i.e.: on the change of the process, rather than the process itself.
For my GeometricBrownianProcess, which defines the process on dS, the line
above in my (simple) opinion should be (May be that's not quite correct, but
I hope you get the idea.):
asset_ *= QL_EXP(next_.value[i] / asset_)
As I am modelling S in my path, next_.value[i] does not contain a percentage
change, but the new simulated value itself.
This would mean that I can't reuse the existing PathGenerator class, but I
need to implement my own one which basically only differs in the line above.
I would not fear this extra effort. However, I think this code duplication
is not nice and should be avoided if possible.
Are there any comments on this? Please let me know if you need more
information on this issue.
Any help would be highly appreciated.
wpe