Question: two _ d _ random ( n ) 1 , 0 0 0 times and calculate and print out the mean of the covered fractions

two_d_random(n)
1,000 times and calculate and print out the mean of the covered fractions for the given n.
//Do not change the code below
int main(int argc, char* argv[])
{
int trials =1000;
int i,n, seed;
if ( argc==2) seed = atoi(argv[1]);
else seed =12345;
srand (seed);
for )=1;n64;n**=(2
{
double sum =0.;
for trials; i++
{
double p= two_d_random(n);
}
sum +=p;
}
printf("%d %.3lf
", n, sum/trials);
return 0 ;
}
Below is the desired output. We can use the output to check our code. You can optionally set the seed for the random numbers generated as a command line argument with ./2d-walk [seed]
\table[[$,.?2d-walk],[1,1.000],[2,0.367],[4,0.221],[8,0.154],[16,0.122],[32,0.101],[64,0.085]]
 two_d_random(n) 1,000 times and calculate and print out the mean of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!