forum

Home / DeveloperSection / Forums / Generate Random numbers uniformly over entire range

Generate Random numbers uniformly over entire range

Anonymous User198207-May-2013
Hi All!

I need to generate random numbers with in specified interval [max,min]

Also the random numbers should be uniformly distributed over interval, not located to particular point

Currenly I am generating as:

for(int i=0;i<6;i++)
{
DWORD random= rand()%(max-min+1) + min;
}
From my tests random numbers are generated around one point only

Example
min= 3604607;
max= 7654607;
Random numbers generated:

3631594
3609293
3630000
3628441
3636376
3621404
Edit (added from answers below): Ok RAND_MAX is 32767. I am on C++ windows platform.. Is there any other method to generate random numbers with uniform distribution?

Thanks in advance! 


Updated on 07-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By