Question
Python Brownian Motion in one-dimension- A random walk is a particular kind of probabilistic simulation that models certain statistical systems such as Brownian motion of
Python Brownian Motion in one-dimension- A random walk is a particular kind of probabilistic simulation that models certain statistical systems such as Brownian motion of molecules. You can think of a one-dimensional random walk in terms of coin flipping. If you flip a coin as heads (x>.5) you take a step forward. If you flip a coin as tails (x<.5) you take a step back. Write a program with a function that takes as input the number of steps "nsteps" for a random walk, and the number of times to simulate it "nsim". Calculate the average distance (in steps, at the end of the walk) from the origin for all nsim simulations. Plot the position over time for 10 simulations and 100 steps, with each simulation colored differently and save the plot as walk.png. Output a CSV named walk.csv containing the positions for 1000 simulations and 1e5 steps. Save this program as "hw4_q3.py"
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