That code doesn't compile:
fprintf(doc," %f %f %f \n\n",y,mean_r,);
You have specified three "%f" parameters in the format string but provided two, and have an empty parameter at the end - you'll get an error for the ",)" part, and a problem when it tries to execute if you remove the ",".
The way I'd do it is to write a function which generated a set of random numbers and returned the average.
Then call that repeatedly for each value of
and print the result.