From: Joel VanderWerf Date: 2004-08-15T09:08:54+09:00 Subject: Re: Random variable library? Charles Mills wrote: > On Aug 14, 2004, at 4:12 PM, Robert Feldt wrote: > >> Joel VanderWerf wrote: >>> It's just that if you need arbitrarily many streams of numbers, then >>> you want to be able to instantiate more generators. Actually, I >>> suppose you could use Kernel#srand to switch between streams. That >>> would be slow, because the state vector has to be recreated each >>> time, but would save on the space needed for all those state vectors. > > Could you explain this more? It was a bad idea. After looking more closely at ruby's random.c, I don't think it's possible. I naively thought the value returned by #srand might be a new seed that encodes the current position in the sequence, but of course is does not, because there are 2^19937-1 distinct positions. So you'd have to save and restore the whole state vector. It's better to follow Robert's suggestion to wrap that state in an object.