Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 2 . ( 5 0 points ) Bounded 2 D Random Walk In this problem, we will write a program to simulate a 2
Exercise points Bounded D Random Walk
In this problem, we will write a program to simulate a random walk. Imagine a random walker starting at the origin that with equal probabilities goes up right, down and left. For example, when the walker is at with equal probability their next location is at or
Given a positive integer a square is defined by the following four points: and We are interested in knowing, on average, what fraction of points within this square the walker visits before they touch one of the edges of the square, given they start their walk from
twodrandomn
times and calculate and print out the mean of the covered fractions for the given
Do not change the code below
int mainint argc, char argv
int trials ;
int seed;
if argc seed atoiargv;
else seed ;
srand seed;
for ;;
double sum ;
for trials;
double twodrandomn;
sum ;
printfd lf
n sumtrials;
return ;
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 dwalk seed
table$walk
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started