Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set minimum for random number generator

79 views
Skip to first unread message

OrganicFreeStyle

unread,
Jun 11, 2006, 11:54:16 AM6/11/06
to
Hi all. I'm programming a model of economic relationships in both
python and ruby near simultaneously, and as with most simulations, I
need to generate a random number within a specific range. I'm a python
man, and in python you can call random.randint(min, max) to achieve
this. Rand allows you to set the max, but what about the min? Is there
a similar method to Python's randint() in Ruby? Alternative random
number generators that have this ability? Thanks.

ZeD

unread,
Jun 11, 2006, 12:14:33 PM6/11/06
to
OrganicFreeStyle wrote:

from a non-ruby developer :)

min + rand (max-min)

--
Under construction

OrganicFreeStyle

unread,
Jun 11, 2006, 12:29:37 PM6/11/06
to

Brilliant. Such elegance! Thank you ZeD, much appreciated.

Serendipity

unread,
Jun 27, 2006, 2:14:46 AM6/27/06
to
>
> min + rand (max-min)
>


Just what I was looking for...thanks!

0 new messages