Re: RandomSequenceGenerator<RNG>: 'dimensionality'

Posted by YuHong-4 on
URL: http://quantlib.414.s1.nabble.com/RandomSequenceGenerator-RNG-dimensionality-tp913p919.html


Yes, calling PathGenerator.next().value shall return one simulated price path.  Thanks!

Regards,

Hong Yu

 

> Subject: RE: [Quantlib-users] RandomSequenceGenerator<RNG>: 'dimensionality'

> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Date: Fri, 15 Jul 2011 15:21:15 +0200
>
>
> If you just want to simulate the paths, just call next() as many times
> you want on the path generator you instantiated. The MonteCarloModel,
> instead, also wants a path pricer; that is, an instance of a class
> inherited from PathPricer that takes a path and returns a realized
> value. That depends on the derivative you want to price; you can see,
> for example, <ql/pricingengines/vanilla/mceuropeanengine.hpp>. Looking
> at this engine will also show you how to instantiate a MC simulation.
>
> Later,
> Luigi
>
>
> On Thu, 2011-07-14 at 15:52 +0000, YuHong wrote:
>
> > Thanks for the suggestions! I have defined the random-sequence
> > generator, and then PathGenerator; then the compilation passed.
> >
> > The whole problem is: I wish to do monte-carlo simulation on
> > geometric-brownian-motion process. So I have defined
> > GeometricBrownianMotion process and associated PathGenerator by using
> > QuantLib, shown in the following code:
> >
> > // u01_rng
> > srand( time(NULL) );
> > Ranlux3UniformRng u01_rng( rand() );
> >
> > // u01_generator
> > RandomSequenceGenerator<Ranlux3UniformRng> u01_generator(
> > num_timeUnits, u01_rng
> > );
> >
> > // gsg
> > typedef
> > InverseCumulativeRsg<RandomSequenceGenerator<Ranlux3UniformRng>,InverseCumulativeNormal> gbm_gsg_type;
> > gbm_gsg_type gsg( u01_generator );
> >
> > // gbm_process
> > boost::shared_ptr<StochasticProcess1D> gbm_process(
> > new GeometricBrownianMotionProcess( S0, miu, sigma )
> > );
> >
> > // gbm_generator_ptr
> > boost::shared_ptr<PathGenerator<gbm_gsg_type> >
> > gbm_generator_ptr(
> > new PathGenerator<gbm_gsg_type>(
> > gbm_process, dt, num_timeUnits, gsg, false
> > )
> > );
> >
> >
> > I wish to apply MonteCarloModel to the above PathGenerator
> > 'gbm_generator_ptr', to simulate multiple price paths. May I ask,
> > what is the correct way to define 'MonteCarloModel' then? Thanks a
> > lot!
> >
> > Regards,
> >
> > Hong Yu
> >
> >
> >
> > > Subject: RE: [Quantlib-users] RandomSequenceGenerator<RNG>:
> > 'dimensionality'
> > > From: [hidden email]
> > > To: [hidden email]
> > > CC: [hidden email]
> > > Date: Wed, 13 Jul 2011 11:39:21 +0200
> > >
> > >
> > > You can define the sequence generator like you were trying to do
> > > previously. In this case, the dimension you'll have to pass will be
> > the
> > > number of steps in the path, since that's how many random numbers
> > you'll
> > > need to generate each path.
> > >
> > > Luigi
> > >
> > >
> > > On Wed, 2011-07-13 at 08:56 +0000, YuHong wrote:
> > > >
> > > > Thanks for the suggestion! So I'd rather present a more important
> > > > question:
> > > >
> > > > ??? usg;
> > > > InverseCumulativeRsg<USG,InverseCumulativeNormal> gsg( ?usg? );
> > > >
> > > > In the above code, I wish to define 'gsg', an instance of class
> > > > InverseCumulativeRsg<USG, InverseCumulativeNorma>. 'gsg' will
> > later
> > > > be used in PathGenerator instance for
> > GeometricBrownianMotionProcess
> > > > simulation. The 'gsg' constructor needs parameter 'usg' of USG
> > type,
> > > > a uniformSequenceGenerator with class method 'dimension()'.
> > > >
> > > > May I ask, how to define the uniformSequenceGenerator 'usg' by
> > using
> > > > QuantLib? Thanks a lot!
> > > >
> > > > Regards,
> > > >
> > > > Hong Yu
> > > >
> > > >
> > > >
> > > > > Subject: Re: [Quantlib-users] RandomSequenceGenerator<RNG>:
> > > > 'dimensionality'
> > > > > From: [hidden email]
> > > > > To: [hidden email]
> > > > > CC: [hidden email]
> > > > > Date: Wed, 13 Jul 2011 10:37:07 +0200
> > > > >
> > > > > On Wed, 2011-07-13 at 08:01 +0000, YuHong wrote:
> > > > > >
> > > > > > I am trying to create a uniformly distributed random sequence
> > > > > > generator via the following code:
> > > > > >
> > > > > > srand( time(NULL) );
> > > > > > Ranlux3UniformRng u01_rng( rand() );
> > > > > > RandomSequenceGenerator<Ranlux3UniformRng>
> > > > > > u01_generator( ?dimensionality?, u01_rng );
> > > > > >
> > > > > > In the above code line-3, I need to specify the
> > 'dimensionality'
> > > > > > parameter. May I ask, what does the 'dimensionality' parameter
> > > > mean,
> > > > > > and how to determine the correct parameter value? Thanks a
> > lot!
> > > > >
> > > > > The RandomSequenceGenerator is for generating tuples (the word
> > > > > 'sequence' might be misleading there.) The dimensionality is the
> > > > size
> > > > > of each tuple you want to be generated. As Obi-Wan Kenobi once
> > said,
> > > > > these are not the droids you're looking for.
> > > > >
> > > > > In your case, you can just use the Ranlux3UniformRng you
> > > > instantiated
> > > > > and call next() repeatedly.
> > > > >
> > > > > Luigi
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > > Brady's First Law of Problem Solving:
> > > > > When confronted by a difficult problem, you can solve it more
> > > > > easily by reducing it to the question, "How would the Lone
> > > > > Ranger have handled this?"
> > > > >
> > > > >
> > > >
> > >
> > > --
> > >
> > > Everything that can be invented has been invented.
> > > -- Charles Duell, Director of U.S. Patent Office, 1899
> > >
> > >
> >
>
> --
>
> Glendower: I can call spirits from the vasty deep.
> Hotspur: Why, so can I, or so can any man;
> But will they come when you do call for them?
> -- King Henry the Fourth Part I, Act III, Scene I
>
>

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric
Ries, the creator of the Lean Startup Methodology on "Lean Startup
Secrets Revealed." This video shows you how to validate your ideas,
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users