October 10th, 2003, 09:27 AM

Frequency of random numbers
I am needing to calculate, first the mean of 1000 random numbers, which i have done (see below code) and then the frequency of each number as a percentage, which i am finding very difficult. Could anyone point me in the right direction?
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int random_number ;
int count, total ;
float mean ;
total = 0 ;
for (count=0; count<1000; count++)
{
random_number = (int) (10.0*rand()/(RAND_MAX+1));
total += random_number; }
mean = (float) total/1000 ;
printf("Mean of random numbers is %f\n",mean) ;
return 0;
}
Thanks
October 10th, 2003, 09:46 AM

I have posted several things on just such a subject, try searching the forum on 'mitakeet' and 'rand' and see what you pull up.
And another thing, enclose your code in "code" tags!