Different Mersenne Twister in different object

Jul 15, 2014 at 3:04pm
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 Jul 15, 2014 at 3:12pm
Jul 15, 2014 at 4:23pm
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/
Jul 16, 2014 at 7:27am
thank you for your reply. Every object should have a different ID. And IDs should uniformly distributed.
Jul 16, 2014 at 11:40am
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.
Jul 21, 2014 at 9:14am
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?
Jul 21, 2014 at 4:37pm
> 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
Jul 23, 2014 at 9:05am
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.
Jul 23, 2014 at 1:09pm
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.