Now, write another function with the interface simulateRandomWalk(nsim,nstep,startPosition) that simulates nsim number of random-walks, each of which contains nstep steps and starts at startPosition. Then, this function calls doRandomWalk() repeatedly for nsim times and finally returns a vector of size nsimcontaining final locations of all of the nsim simulated random-walks.
Write a function with the interface doRandomWalk(nstep,startPosition), that takes the number of steps nstep for a random walk and the startPosition of the random walk on a straight line, and returns the location of the final step of the random walker.
Problem Part B
Now, write another function with the interface simulateRandomWalk(nsim,nstep,startPosition) that simulates nsim number of random-walks, each of which contains nstep steps and starts at startPosition. Then, this function calls doRandomWalk() repeatedly for nsim times and finally returns a
Problem Part C
Now write a script that plots the output of simulateRandomWalk() for
The resulting plot should look like the following,
How do you interpret this result? How can uniformly-distributed random final steps end up having a Gaussian bell-shape distribution.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









