|
From: David K. <dk...@gm...> - 2023-08-31 14:52:54
|
I would like to run a MC simulation, something like:
ext::shared_ptr<StochasticProcess1D> diffusion(new
GeometricBrownianMotionProcess(1.0, 0.0, sigma_));
LowDiscrepancy::rsg_type RSG =
LowDiscrepancy::make_sequence_generator(nTimeSteps, seed);
typedef SingleVariate<LowDiscrepancy>::path_generator_type
generator_type;
ext::shared_ptr<generator_type> myPathGenerator(new
generator_type(diffusion, T, nTimeSteps, RSG, brownianBridge));
MonteCarloModel<SingleVariate,
LowDiscrepancy>McSimulation(myPathGenerator, myPathPricer,
statisticsAccumulator, false);
McSimulation.addSamples(nSamples);
But instead of using a GeometricBrownianMotionProcess I just want a simple
IID process. I managed to fake it out by setting my time steps to be of
length 1 and then defining a StochasticProcess1D where the drift term is
drift(t, x) = -x. Ugly kludge.
Instead I tried to define my own IIDPathGenerator as a derived class from
PathGenerator in a way that would allow me to define IID paths (the term
"path" is obviously a misnomer in this case). But this doesn't work since
the "next()" method of PathGenerator isn't virtual, so when I pass it as an
argument to MCSimulation the base class's "next()" method is called.
Note: I am a total newbie to QuantLib and my C++ is rusty, so please be
patient...
Thanks,
David Klein
|