I need to generate random numbers within a specified interval, [max;min].
Also, the random numbers should be uniformly distributed over the interval, not located to
This is not the code, but this logic may help you.
static double rnd(void)
{
return (1.0 / (RAND_MAX + 1.0) * ((double)(rand())) );
}
static void InitBetterRnd(unsigned int seed)
{
register int i;
srand( seed );
for( i = 0; i < POOLSIZE; i++){
pool[i] = rnd();
}
}
// This function returns a number between 0 and 1
static double rnd0_1(void)
{
static int i = POOLSIZE-1;
double r;
i = (int)(POOLSIZE*pool[i]);
r = pool[i];
pool[i] = rnd();
return (r);
}