title: Evaluating Random Number Generator as per Knuth [2, 41-79]
body: <p>I have created a random number generator using gettimeofday() function, in C. Now,I need to evaluate this using statistical or empirical methods developed by Knuth. I searched exhaustively for the same, but could not find a workable solution. Or I may be wrong. Please help me in evaluating this RNG according to the above standards.</p>
  
  <pre><code>#include &lt;sys/time.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int* randgen(int num, int limit){
  char buffer[30];
  struct timeval tv;
  time_t curtime;
  gettimeofday(&amp;tv, NULL); 
  int* numbers = malloc(sizeof(int)*num);
  int i = 0;
  int j;
  while(num != 0){
      gettimeofday(&amp;tv, NULL); 
      for(j = 0; j &lt; 1000; j++);
      numbers[i] = tv.tv_usec % (limit+1);
      num--;
      i++;
  
  }
  return numbers;
  }
  
  
  int main(void)
  {
  
    FILE *fp;
    fp = fopen("random.txt","w+");
    printf("\nEnter the number of random integers needed\t:\t");
    int num;
    scanf("%d",&amp;num);
    printf("\nEnter the MAX limit for the random numbers\t:\t");
    int limit;
    scanf("%d",&amp;limit);
  
    int* result = randgen(num,limit);
    int i = 0;
    printf("\n");
    for( i = 0 ; i &lt; num ; i++ ){
  printf(" %d ",*(result+i));
  fprintf(fp,"%d ",*(result+i));
  
    }
  return 0;
  
  }
  </code></pre>