Login  Register

Re: RandomNumberGenerator

Posted by mike.parkerql on Jun 06, 2004; 3:07pm
URL: http://quantlib.414.s1.nabble.com/RandomNumberGenerator-tp2978p2979.html

check out rngtraits.hpp and rngtypedefs.hpp

The default pseudo random generator is Mersenne Twister Uniform generator with
inverse cumulative normal to convert to gaussian. See typedef PseudoRandom.

e.g.
                Size dim1 = 20; //sequence length.
                long seed = 12345;

                GaussianRandomSequenceGenerator grsg =
PseudoRandom::make_sequence_generator(dim1, seed);
                Sample<Array> res = grsg.nextSequence();
                std::cout << res.value <<std::endl;
                std::cout << std::endl;



Examples of usage in e.g. mcvanillaengine.hpp

or could try,
                typedef GenericPseudoRandom<KnuthUniformRng,
InverseCumulativeNormal> fred;
                fred::rsg_type gen = fred::make_sequence_generator(dim1, seed);
                std::cout << gen.nextSequence().value <<std::endl;

Also, check out random numbers namespace. Example below uses Box-Mueller
method of transforming uniforms into gaussians.

                BoxMullerGaussianRng<MersenneTwisterUniformRng> bm_grsg(seed);
                for (Size sim=0; sim<10; sim++)
                        std::cout << bm_grsg.next().value << std::endl;

                BoxMullerGaussianRng<KnuthUniformRng> bm_grsg(seed); etc.

Hope this helps.

Mike

Quoting John Kiff <[hidden email]>:

> Could someone please give me some pointers to where I can find out more about
> setting the key
> parameters of the RandomNumberGenerator function: "dimension", "samples",
> "RNGType" and "seed"?
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/ 
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the new InstallShield X.
> From Windows to Linux, servers to mobile, InstallShield X is the one
> installation-authoring solution that does it all. Learn more and
> evaluate today! http://www.installshield.com/Dev2Dev/0504
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


--