views:

27

answers:

2

Hi Guys,

I need to know the effect of different platforms on the System.Random object (Silverlight). Is the sequence created the same on Mac, PC and across 32 / 64 bit?

Regards

Tris

+1  A: 

Tris,

excuse my "stupid" answer, but to my mind, Random numbers should be always considered random and thus the created sequences should be handled as NOT same across any "domain". I know that the .NET (or Silverlight) random number generators use a Pseudo-random algorithm depending on the seed value and will generate the same number sequence when using the same seed value, but I just wouldn't rely on this fact.

It seems that you have some kind of "expectation" when you need to have random numbers synchronized across several platforms, and using a Random Number generator for expected value sequences looks weird to me.

If you can tell us more about your use case, maybe we can find another more solid solution?

Just my opinion.

Best regards, Thomas

moonground.de
There are times however where a repeat of a "random" sequence is useful, in simulation software its quite a common requirement. I see no need to distrust the repeatability of the `Random` object for a given seed. This should be transferable to all platforms. One caveat would be where multiple threads may allocate numbers from the same instance of `Random`, in this case an additional random element has been introduced. In this case the code may pull random numbers in a different "order" than a previous run even with the same seed.
AnthonyWJones
Thanks for the clarification, Anthony. To my understanding you should store/restore a list of random Items when you have the need to repeat/synchronize it anytime, but I guess they might become a huge resource hog and someone might choose a "repeatable" Random generator for such reasons..
moonground.de
A: 

The algorithm to generate the random numbers is encoded into the runtime. Hence regardless of the platform you should see the same set of "random" numbers for a given seed value.

The extact behaviour of default constructor for Random (where the seed value is time based) may vary slightly from platform to platform. For example rapid creation of instances of Random may create some instances that generate the same sequence, the distribution of these "duplicates" may vary on all sorts of conditions including the platform.

AnthonyWJones