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.
OrganicFreeStyle wrote: > 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.
> > 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.
> from a non-ruby developer :)
> min + rand (max-min)
> -- > Under construction
Brilliant. Such elegance! Thank you ZeD, much appreciated.