Random Numbers

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Random Numbers

animesh
  What is the method used for Random number generation in QuantLib for
Monte Carlo Simulations (for instance Heston Model)?
Is it Mersene Twister or something else?

--
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)
Ph: (+91)9920098221


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: [Quantlib-dev] Random Numbers

Luigi Ballabio
On Thu, 2010-09-16 at 13:19 +0530, animesh saxena wrote:
> What is the method used for Random number generation in QuantLib for
> Monte Carlo Simulations (for instance Heston Model)?
> Is it Mersene Twister or something else?

It depends on the traits you choose when you instantiate the engine.
For the PseudoRandom traits, it's Mersenne Twister.  For LowDiscrepancy,
it's Sobol.  If you want something else, you can make a new traits class
and use that one; look at <ql/math/randomnumbers/rngtraits.hpp> and
<ql/methods/montecarlo/mctraits.hpp> for examples and details.

Luigi


--

standards, n.:
The principles we use to reject other people's code.



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: [Quantlib-dev] Random Numbers

animesh
  Hi Luigi,
       Thanks for your mail. I think I might have tried Mersenne twister
(from sample code), coz the sequence gave my code convergence issues. I
initially went with my own implementation of Halton sequence to improve
the convergence, but well Sobol is much much better :)

I had used Cholesky decomposition for generating correlated random
numbers. Using some of the code from QuantLib I am able to generate an N
dimension array. If I have this huge array I can use it for pricing
almost any exotic (by repeating the simulations). All that changes is
the payoff function. For instance Heston model combined with Path
generation can be used for pricing almost any exotic structure (well
majority of them). I still am trying to think of how to make the payoff
specification generic.

So is it possible to have a generic pricer in QuantLib which will allow
the user to specify a PayOff function using the multi path generated
above? I think it can be pretty useful. Coz currently as you mentioned
we have Engines tightly coupled with Exotic Options and Processes.

Let me know your views on that.

Thanks,

Animesh
On 9/16/10 2:57 PM, Luigi Ballabio wrote:

> On Thu, 2010-09-16 at 13:19 +0530, animesh saxena wrote:
>> What is the method used for Random number generation in QuantLib for
>> Monte Carlo Simulations (for instance Heston Model)?
>> Is it Mersene Twister or something else?
> It depends on the traits you choose when you instantiate the engine.
> For the PseudoRandom traits, it's Mersenne Twister.  For LowDiscrepancy,
> it's Sobol.  If you want something else, you can make a new traits class
> and use that one; look at<ql/math/randomnumbers/rngtraits.hpp>  and
> <ql/methods/montecarlo/mctraits.hpp>  for examples and details.
>
> Luigi
>
>

--
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)
Ph: (+91)9920098221


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: [Quantlib-dev] Random Numbers

animesh
  Also FYI convergence diagram for my code (3 Asset basket option) with
Stochastic Vol (less than 30 seconds to price)

http://quantanalysis.files.wordpress.com/2010/09/091510_2334_montecarlob101.jpg

On 9/16/10 3:25 PM, animesh saxena wrote:

>  Hi Luigi,
>       Thanks for your mail. I think I might have tried Mersenne
> twister (from sample code), coz the sequence gave my code convergence
> issues. I initially went with my own implementation of Halton sequence
> to improve the convergence, but well Sobol is much much better :)
>
> I had used Cholesky decomposition for generating correlated random
> numbers. Using some of the code from QuantLib I am able to generate an
> N dimension array. If I have this huge array I can use it for pricing
> almost any exotic (by repeating the simulations). All that changes is
> the payoff function. For instance Heston model combined with Path
> generation can be used for pricing almost any exotic structure (well
> majority of them). I still am trying to think of how to make the
> payoff specification generic.
>
> So is it possible to have a generic pricer in QuantLib which will
> allow the user to specify a PayOff function using the multi path
> generated above? I think it can be pretty useful. Coz currently as you
> mentioned we have Engines tightly coupled with Exotic Options and
> Processes.
>
> Let me know your views on that.
>
> Thanks,
>
> Animesh
> On 9/16/10 2:57 PM, Luigi Ballabio wrote:
>> On Thu, 2010-09-16 at 13:19 +0530, animesh saxena wrote:
>>> What is the method used for Random number generation in QuantLib for
>>> Monte Carlo Simulations (for instance Heston Model)?
>>> Is it Mersene Twister or something else?
>> It depends on the traits you choose when you instantiate the engine.
>> For the PseudoRandom traits, it's Mersenne Twister.  For LowDiscrepancy,
>> it's Sobol.  If you want something else, you can make a new traits class
>> and use that one; look at<ql/math/randomnumbers/rngtraits.hpp>  and
>> <ql/methods/montecarlo/mctraits.hpp>  for examples and details.
>>
>> Luigi
>>
>>
>

--
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)
Ph: (+91)9920098221


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users