code for generating random samples!
lets come straight to the point.
i have to write a piece of code in C to generate "INDEPENDENT AND UNIFORM (RANDOM) SAMPLES" from a given interval.
since i am a complete zero when it comes to statistics, any help will be greatly appreciated.
There are different random number generators. However, for
some good random number you may use the glibc functions:
srand48(time(NULL); // initializing random number generator, may be used as
srand48(0); // to always get the same numbers. (for testing)
drand48(); // gives a double between 0 and 1.
int myNumber = (int) (drand48() * MAX_VALUE + 1.0); // for numbers between 1 and MAX_VALUE.
Thanks a lot!
|All times are GMT -5. The time now is 06:32 PM.|