for(int i=0;i<100;i++)
for(int j=0;i<6;j++)
{
cout<<rand()%6<<"," // Store these numbers in a map
}
cout<<endl;
Say, suppose I store these random numbers in the inner for loop in a map<int,myRandomNumbers>
In some random game, game maker also created a similar call to rand()%6 to get all 6 numbers. Are these 6 numbers having any slightest chance to be fully or partially the same as one of myRandomNumbers ?
Well, you can calculate it, assuming
rand()gives a completely uniform distribution (it doesn’t, but we’ll assume it does anyway). If you generate 6 random numbers in the range[0, 5], the probability that another set of 6 random numbers generated from the same range are exactly the same is(1/6)^6 ~ 2.14e-5. You can use the binomial distribution to calculate the probability that they will be partially similar, that is, match innplaces for n in[0, 6].