Constraining Random Values

   3437   2   0
User Avatar
Member
113 posts
Joined: July 2005
Offline
Hi,

I'm looking for a way to constrain the result fo a random value for example between 2.5 and 5.
By the way is there an other expression to generate random values instead of “rand” ?


Thanks in advance. 8)

Julien
User Avatar
Member
4140 posts
Joined: July 2005
Offline
Yup - you actually *want* to have functions like rand() to be normalized like that - helps you keep things in a nice 0-1 range until you're ready to rescale it to a new domain. The “fit” function will do this for you.

Anyway - an expression that you can use to put a random number with a seed of “$foo” ranging from 2.5 to 5 is

fit(rand($foo), 0, 1, 2.5, 5)

Cheers,

J.C.
John Coldrick
User Avatar
Member
113 posts
Joined: July 2005
Offline
thanks !


Julien.
  • Quick Links