Can someone remind me of the name for the class/method for generating random
numbers? I did a quick grep through the library and a google, but all I
found was a project that plans to improve the random number generator(s).
Can someone remind me of the name for the class/method for generating random
numbers? I did a quick grep through the library and a google, but all I
found was a project that plans to improve the random number generator(s).
Can someone remind me of the name for the
class/method for generating random numbers?
Would you believe....... rand?
Kernel#rand takes one optional parameter that if 0 (the default) returns
a Float x such that 0 <= x < 1, and if not zero, returns an Integer x such
that 0 <= x <= parameter. Use Kernel#srand to seed the random number
generator.
On Tue, Jul 29, 2003 at 06:19:58AM +0900, Harry Ohlsen wrote:
Can someone remind me of the name for the class/method for generating random
numbers? I did a quick grep through the library and a google, but all I
found was a project that plans to improve the random number generator(s).
Can someone remind me of the name for the class/method for generating random
numbers? I did a quick grep through the library and a google, but all I
found was a project that plans to improve the random number generator(s).
Thanks in advance,
Harry O.
oban:~# irb
irb(main):001:0> rand(10)
=> 8
You have the rand method.
rand(n) return a number in [1…n-1].
Can someone remind me of the name for the class/method for
generating random numbers?
Nobody did ask this so far: What kind of random numbers do you need
and for what purpose.
Ruby’s RNG may be nice for Monte Carlo simulations (because it has a
very large period) but it is NOT SECURE for CRYPTOGRAPHY as it is.
You may wish to visit
Can someone remind me of the name for the
class/method for generating random numbers?
Would you believe....... rand?
Kernel#rand takes one optional parameter that if 0 (the default)
returns a Float x such that 0 <= x < 1, and if not zero, returns an Integer
x such that 0 <= x <= parameter. Use Kernel#srand to seed the random
number generator.
Can someone remind me of the name for the class/method for
generating random numbers?
Nobody did ask this so far: What kind of random numbers do you need
and for what purpose.
That’s a good question. I’m no statistics guru, so I probably don’t really
know :-).
However, I’m guessing that uniformly distributed is probably fine, which I
think is what rand() tries to generate.
What I’m using them for is to try to find a generator in Z_n. I plan to do
some experimentation to see whether doing it that way (there’s a little more
to the approach, but it’s basically random) compared to using brute force
(ie, checking the order of 2, 3, … until we find one that’s phi(n)).
Ruby’s RNG may be nice for Monte Carlo simulations (because it has a
very large period) but it is NOT SECURE for CRYPTOGRAPHY as it is.
Thanks. It might be good for my experiment. I’ll take a look.
Harry O.
···
On Thu, 31 Jul 2003 06:28, Josef ‘Jupp’ Schugt wrote:
Can someone remind me of the name for the class/method for
generating random numbers?
> Nobody did ask this so far: What kind of random numbers do you
> need and for what purpose.
> Ruby's RNG may be nice for Monte Carlo simulations (because it
> has a very large period) but it is NOT SECURE for CRYPTOGRAPHY
> as it is. You may wish to visit
> http://www.math.keio.ac.jp/matumoto/emt.html
> Gis,
> Josef 'Jupp' Schugt -- N'attribuez jamais à la malice ce que
> l'incompétence explique ! -- Napoléon
Actually, Ruby’s RNG isn’t so great for Monte Carlo or discrete event
simulations. I’d only use it for games. The problem isn’t the
quality of the generator (I think Matz is using the Mersenne twister
algorithm). It’s that “randomness” is obtained by a method rather
than a Random class which can instantiate Random objects. If there
were separate random objects, each of which maintained its own seed
state, it would be much easier to create designed experiments with
common or antithetic random variates which you could exploit for
variance reduction. Having a method restricts you to a single stream
of randomness unless you’re willing to go through contortions.