Question: Do not forget to submit your work to gradescope before the deadline. A Makefile is provided.Exercise 1 . ( 5 0 points ) DiffusionIn this
Do not forget to submit your work to gradescope before the deadline. A Makefile is provided.Exercise points DiffusionIn this exercise, we use a D random walk to simulate a diffusion process.Imagine a particle starting atthe origin that has equal probabilities to go in possible directions left, right, backward, forward, down, and up For example, when the particle is at z y z with equal probability its next location isat U orThe particle will conduct the random walk for n steps. We are interested in the distribution of the final locations of particles after each takes n steps.Specifically, we would like to know the distribution of thedistance between the final location and the origin. In order to obtain this distribution, we simulate m such particles, and check the proportion of the particles that lies within rn distance from the origin, where r is a real number between and Note all the particles will be within a sphere with radius n since particles only move n steps and the furthest they can go is a distance n from the origin. In our simulation, we will calculatethe proportion of particles that are within rn from the origin for r Below is the main function for this program. Note how we use command line arguments. int main int arg, char argif arge printi Usage: a n aa argv : return ;int n atoiargv ;int n atoiargv ;srand :diffusionn m;return ;We need to implement the function void diffusion int n int mIn this function, we need to dynamically allocate memory to represent a D grid where z y coordinates range from n to n For all the possible z y z coordinates within the range, we save the number of particles that end up at the location ry During the simulation, if the final location of a particle is r y the corresponding value will be incremented by Generate a random number using rand If this number is or you should move left or right on the xaxis, respectively. If it is or you should move up or down on the yaxis, respectively. If it is or move up or down on the zaxis, respectively.In the implementation of main, we use the below function to print out results.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
