views:

44

answers:

4

I have a computation/simulation system with one master server and (potentially) many clients (workers). All of them are working with the same data but need random numbers for the computation.

What would be the best PRNG and the best way to seed it to make sure that two clients aren't using the same cycle and computing the same results twice.

+1  A: 

Couple of ideas, seed it from something unique on the client such as the MAC address of the client.

Or, have the master generate a random number and pass that as the seed to use with the work item to the client.

Paolo
A: 

How random do you need them to be?

boost-random has some PRNGs that I believe have some good theoretical background on them if you need it. You can make sure to use different seeds by having your server hand out the seeds together with the work.

villintehaspam
+2  A: 

One of the joys of random numbers is that you can't guarantee the sequences aren't identical. However, you can make it unlikely by xoring the time and something unique to the system -- the MAC address, a hash of the Name, or the IP address come to mind.

Joel
+1  A: 

The problem with seeding from something machine based (MAC address, name, IP address) is that the seed will always be the same on the same machine.

Usually seeds come from the current time. If all the worker machines start their process at the same time then they will all have the same seed.

Easiest way to deal with this is to combine the two values. Generating a seed from a machine hash and the current time will give you a unique seed per machine that changes after each run.

Another option to create a random number generator on the master, and have each worker get its seed from the master.

Cameron MacFarland
I guess I'll go with combination of the two - each machine will use time and number from the master for it's seed. I have no idea how unique cycles will this produce from theoretical point of view, maybe I can reseed it every few thousand numbers with next number from master. Would that help or make it even worse?
lacop