# Multiple Instance of rand?

**URL:** <https://www.ruby-forum.com/t/multiple-instance-of-rand/107695>\
**Category:** Ruby\
**Created:** [June 25, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695 "2007-06-25T13:56:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 25, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/1 "2007-06-25T13:56:40Z")

</div>

Is it possible to have multiple instances Ruby’s random-number  
generator running within one program? I would like to have different  
random sequences, each with its own seed.

---

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 25, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/2 "2007-06-25T19:35:14Z")

</div>

are wrote:

> Is it possible to have multiple instances Ruby’s random-number  
> generator running within one program? I would like to have different  
> random sequences, each with its own seed.

Not yet, but it has been proposed for 1.9.

The best workaround for now is to use one of the external PRNG  
libraries.

---

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 26, 2007, 3:16pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/3 "2007-06-26T15:16:34Z")

</div>

On 26/06/07, are [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks much. I’m kind of a noob; could you please give me a hint as  
> to what the PRNG libraries are and where I would find them?

Try searching within these sites:  
[http://rubyforge.org/](http://rubyforge.org/)  
[http://raa.ruby-lang.org/](http://raa.ruby-lang.org/)

---

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 26, 2007, 12:51pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/4 "2007-06-26T12:51:12Z")

</div>

Thanks much. I’m kind of a noob; could you please give me a hint as  
to what the PRNG libraries are and where I would find them?

---

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 26, 2007, 4:24pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/5 "2007-06-26T16:24:39Z")

</div>

> Thanks much. I’m kind of a noob; could you please give me a hint as  
> to what the PRNG libraries are and where I would find them?

A PRNG is a pseudo random number generator - “pseudo” here expresses the  
fact  
that a computer is a deterministic device, so some tweaking is necessary  
to make it difficult to predict the next “random” number …

You can get an implementation for Ruby here:

[http://rubyvm.sourceforge.net/subprojects/randomr/](http://rubyvm.sourceforge.net/subprojects/randomr/)

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![are](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@are](https://www.ruby-forum.com/u/are)\
**Post date:** [June 26, 2007, 4:58pm UTC](https://www.ruby-forum.com/t/multiple-instance-of-rand/107695/6 "2007-06-26T16:58:42Z")

</div>

On Tue, 26 Jun 2007, are wrote:

> Thanks much. I’m kind of a noob; could you please give me a hint as  
> to what the PRNG libraries are and where I would find them?

There is [http://rubyforge.org/projects/crypt-isaac](http://rubyforge.org/projects/crypt-isaac)

ISAAC is a cryptographically secure PRNG (the mersenne twister, which is  
what Ruby uses, produces quality streams of numbers, butis not  
cryptographically secure).

That is a pure Ruby implementation. I have a version that has a C  
extension that I have been sitting on for quite some time. I’ll make  
some  
time today to get that version packaged and uploaded, though.

Kirk H.
