Different Mersenne Twister in different object

Dear All
I am working with Mersenne Twister in the distributed network. In the network I have a different nodes which have different IDs. These IDs are generated by MT. These IDs should be uniform and unique. I am looking for a way to run MT for different nodes or objects which are completely independent.
for example: node 1 has a MT inside and generate one ID.
node 2 has the MT and generate another ID.
I am wondering if anyone could help me?
Best,
Ameneh
Last edited on
Could you clarify what "These IDs are generated by MT. These IDs should be uniform and unique." means?

This thread may be of interest: http://www.cplusplus.com/forum/general/125320/
thank you for your reply. Every object should have a different ID. And IDs should uniformly distributed.
If these IDs can be the raw integer values generated by the Mersenne Twister algorithm (say, the 32-bit unsigned int values generated by std::mt19937):

a. Use the same seed / seed sequence for all the std::mt19937s on different nodes.

b. For each node, generate an id using something like like this:

1
2
3
4
5
6
std::uint_fast32_t generate_id( unsigned int masked_ipv4_address_of_the_node_as_uint, std::mt19937& twister )
{
    std::set<std::uint_fast32_t> ids ;
    while( ids.size() <= masked_ipv4_address_of_the_node_as_uint ) ids.insert( twister() ) ;
    return *( ids.rbegin() ) ;
}



The other option is to use a central id-server node which can service requests to generate unique non-repeating random ids.
Thanks. I have another question, uniform random number needs the uniform seeds or not.
Do we have a rule or some properties for seeds?
Or, seeds can be any thing without restriction?
> I have another question, uniform random number needs the uniform seeds or not.

I don't quite understand the question. Could you elaborate?


> Do we have a rule or some properties for seeds?
> Or, seeds can be any thing without restriction?

In general, a seed sequence that eliminates statistical bias should be used.
For engines with a fair amount of internal state (large entropy), std::seed_seq comes in handy.
http://en.cppreference.com/w/cpp/numeric/random/seed_seq

There was some discussion about this in this earlier thread:
http://www.cplusplus.com/forum/beginner/131417/#msg709513
I am so grateful for your reply.
I mean : if we want to have a uniform random numbers, seeds are also should be uniform or not.
Random number engines (like std::mt19937) are required to generate integer sequences with a uniform distribution. The seeds need not be uniformly distributed for that.
Topic archived. No new replies allowed.