-   Programming (
-   -   code for generating random samples! (

aru_04 07-20-2005 10:25 AM

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.

traene 07-20-2005 01:49 PM

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.

aru_04 07-21-2005 09:35 AM

Thanks a lot!

All times are GMT -5. The time now is 11:47 PM.