Singleton for SeedGenerator

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

Singleton for SeedGenerator

JinhuaColin Huang
Hi all,

I am wondering why to make seedGenerator a singleton in Quantlib. In my perspective, it is possible to have two identical generators or seeds. Does anybody has some ideas? 

Colin Huang
Master of Financial Mathematics
University of Minnesota-Twin Cities
Phone: 612-300-1585

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Singleton for SeedGenerator

Luigi Ballabio
You can create a random generator and pass a seed explicitly; and if
you use the same seed to create two generators, you'll end up with two
identical generators.

If you don't pass a seed (or if you pass 0), then SeedGenerator comes
in. In that case, the idea is that seeds should be different (because
if you don't pass a seed and so ask for a random one, the expectation
is that you don't end up with identical generators when you do it
twice).

Luigi



On Fri, Jan 17, 2014 at 6:30 PM, Colin Huang <[hidden email]> wrote:

> Hi all,
>
> I am wondering why to make seedGenerator a singleton in Quantlib. In my
> perspective, it is possible to have two identical generators or seeds. Does
> anybody has some ideas?
>
> Colin Huang
> Master of Financial Mathematics
> University of Minnesota-Twin Cities
> Phone: 612-300-1585
> Email:  [hidden email]
> LinkedIn: http://www.linkedin.com/pub/jinhua-colin-huang/2b/a4b/460
> Blog: http://jinhuahuang.blogspot.com/
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

R: Singleton for SeedGenerator

Ballabio Gerardo-4
There is probably a misunderstanding here. I guess that Colin is concerned that, if he creates two random number generators, they'll be in fact the SAME generator and thus will read concurrently from the same random numbers sequence (say, one will pick the 1st, 3rd, 5th... number while the other will pick the 2nd, 4th, 6th...).
But if I understand correctly, the RANDOM NUMBER GENERATOR class isn't a singleton, only the SEED GENERATOR class is. So you CAN have identical but distinct random number generators that won't step on each other's toes. Is that correct?

Gerardo



Gerardo Ballabio
Risk Management

Banca Profilo S.p.A.
Via Cerva 28 - 20122 Milano
Tel. +39 02 58408.463
www.bancaprofilo.it




-----Messaggio originale-----
Da: Luigi Ballabio [mailto:[hidden email]]
Inviato: giovedì 23 gennaio 2014 12.30
A: Colin Huang
Cc: QuantLib users
Oggetto: Re: [Quantlib-users] Singleton for SeedGenerator

You can create a random generator and pass a seed explicitly; and if you use the same seed to create two generators, you'll end up with two identical generators.

If you don't pass a seed (or if you pass 0), then SeedGenerator comes in. In that case, the idea is that seeds should be different (because if you don't pass a seed and so ask for a random one, the expectation is that you don't end up with identical generators when you do it twice).

Luigi



On Fri, Jan 17, 2014 at 6:30 PM, Colin Huang <[hidden email]> wrote:

> Hi all,
>
> I am wondering why to make seedGenerator a singleton in Quantlib. In
> my perspective, it is possible to have two identical generators or
> seeds. Does anybody has some ideas?
>
> Colin Huang
> Master of Financial Mathematics
> University of Minnesota-Twin Cities
> Phone: 612-300-1585
> Email:  [hidden email]
> LinkedIn: http://www.linkedin.com/pub/jinhua-colin-huang/2b/a4b/460
> Blog: http://jinhuahuang.blogspot.com/
>
> ----------------------------------------------------------------------
> -------- CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical
> Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.
> clktrk _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div style="font-family:Calibri;font-size:10px">
Banca Profilo S.p.A.
Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
Capitale Sociale Euro 136.794.106,00 i.v.
Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
Iscritta all’Albo delle Banche e dei Gruppi bancari
Aderente al Fondo Interbancario di Tutela dei depositi
Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.


DISCLAIMER:
The information transmitted may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the material from any computer.
</div>
</body>
</html>


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Singleton for SeedGenerator

Luigi Ballabio
Correct.

On Thu, Jan 23, 2014 at 12:46 PM, Ballabio Gerardo
<[hidden email]> wrote:

> There is probably a misunderstanding here. I guess that Colin is concerned that, if he creates two random number generators, they'll be in fact the SAME generator and thus will read concurrently from the same random numbers sequence (say, one will pick the 1st, 3rd, 5th... number while the other will pick the 2nd, 4th, 6th...).
> But if I understand correctly, the RANDOM NUMBER GENERATOR class isn't a singleton, only the SEED GENERATOR class is. So you CAN have identical but distinct random number generators that won't step on each other's toes. Is that correct?
>
> Gerardo
>
>
>
> Gerardo Ballabio
> Risk Management
>
> Banca Profilo S.p.A.
> Via Cerva 28 - 20122 Milano
> Tel. +39 02 58408.463
> www.bancaprofilo.it
>
>
>
>
> -----Messaggio originale-----
> Da: Luigi Ballabio [mailto:[hidden email]]
> Inviato: giovedì 23 gennaio 2014 12.30
> A: Colin Huang
> Cc: QuantLib users
> Oggetto: Re: [Quantlib-users] Singleton for SeedGenerator
>
> You can create a random generator and pass a seed explicitly; and if you use the same seed to create two generators, you'll end up with two identical generators.
>
> If you don't pass a seed (or if you pass 0), then SeedGenerator comes in. In that case, the idea is that seeds should be different (because if you don't pass a seed and so ask for a random one, the expectation is that you don't end up with identical generators when you do it twice).
>
> Luigi
>
>
>
> On Fri, Jan 17, 2014 at 6:30 PM, Colin Huang <[hidden email]> wrote:
>> Hi all,
>>
>> I am wondering why to make seedGenerator a singleton in Quantlib. In
>> my perspective, it is possible to have two identical generators or
>> seeds. Does anybody has some ideas?
>>
>> Colin Huang
>> Master of Financial Mathematics
>> University of Minnesota-Twin Cities
>> Phone: 612-300-1585
>> Email:  [hidden email]
>> LinkedIn: http://www.linkedin.com/pub/jinhua-colin-huang/2b/a4b/460
>> Blog: http://jinhuahuang.blogspot.com/
>>
>> ----------------------------------------------------------------------
>> -------- CenturyLink Cloud: The Leader in Enterprise Cloud Services.
>> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical
>> Workloads, Development Environments & Everything In Between.
>> Get a Quote or Start a Free Trial Today.
>> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.
>> clktrk _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head></head>
> <body>
> <div style="font-family:Calibri;font-size:10px">
> Banca Profilo S.p.A.
> Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
> Capitale Sociale Euro 136.794.106,00 i.v.
> Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
> Iscritta all’Albo delle Banche e dei Gruppi bancari
> Aderente al Fondo Interbancario di Tutela dei depositi
> Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
> Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.
>
>
> DISCLAIMER:
> The information transmitted may contain confidential and/or privileged material.
> Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient is prohibited.
> If you received this in error, please contact the sender and delete the material from any computer.
> </div>
> </body>
> </html>
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Singleton for SeedGenerator

JinhuaColin Huang
In reply to this post by Ballabio Gerardo-4
Thank you guys. You both answer my question.

Best,


Colin Huang
Master of Financial Mathematics
University of Minnesota-Twin Cities
Phone: 612-300-1585


On Thu, Jan 23, 2014 at 5:46 AM, Ballabio Gerardo <[hidden email]> wrote:
There is probably a misunderstanding here. I guess that Colin is concerned that, if he creates two random number generators, they'll be in fact the SAME generator and thus will read concurrently from the same random numbers sequence (say, one will pick the 1st, 3rd, 5th... number while the other will pick the 2nd, 4th, 6th...).
But if I understand correctly, the RANDOM NUMBER GENERATOR class isn't a singleton, only the SEED GENERATOR class is. So you CAN have identical but distinct random number generators that won't step on each other's toes. Is that correct?

Gerardo



Gerardo Ballabio
Risk Management

Banca Profilo S.p.A.
Via Cerva 28 - 20122 Milano
Tel. +39 02 58408.463
www.bancaprofilo.it




-----Messaggio originale-----
Da: Luigi Ballabio [mailto:[hidden email]]
Inviato: giovedì 23 gennaio 2014 12.30
A: Colin Huang
Cc: QuantLib users
Oggetto: Re: [Quantlib-users] Singleton for SeedGenerator

You can create a random generator and pass a seed explicitly; and if you use the same seed to create two generators, you'll end up with two identical generators.

If you don't pass a seed (or if you pass 0), then SeedGenerator comes in. In that case, the idea is that seeds should be different (because if you don't pass a seed and so ask for a random one, the expectation is that you don't end up with identical generators when you do it twice).

Luigi



On Fri, Jan 17, 2014 at 6:30 PM, Colin Huang <[hidden email]> wrote:
> Hi all,
>
> I am wondering why to make seedGenerator a singleton in Quantlib. In
> my perspective, it is possible to have two identical generators or
> seeds. Does anybody has some ideas?
>
> Colin Huang
> Master of Financial Mathematics
> University of Minnesota-Twin Cities
> Phone: <a href="tel:612-300-1585" value="+16123001585">612-300-1585
> Email:  [hidden email]
> LinkedIn: http://www.linkedin.com/pub/jinhua-colin-huang/2b/a4b/460
> Blog: http://jinhuahuang.blogspot.com/
>
> ----------------------------------------------------------------------
> -------- CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical
> Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.
> clktrk _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div style="font-family:Calibri;font-size:10px">
Banca Profilo S.p.A.
Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
Capitale Sociale Euro 136.794.106,00 i.v.
Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
Iscritta all’Albo delle Banche e dei Gruppi bancari
Aderente al Fondo Interbancario di Tutela dei depositi
Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.


DISCLAIMER:
The information transmitted may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the material from any computer.
</div>
</body>
</html>



------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users