Consider particle “P” having random walk in 1-D, Let N steps of equal length be taken along a line.

8 views (last 30 days)
Consider particle “P” having random walk in 1-D, Let N steps of equal length be taken along a line. Let be the probability of taking a step to the right, the probability of taking a step to the left, “a” the number of steps taken to the right, and “b” the number of steps taken to the left. Write a MATLAB that calculates and plot the following parameters:
  • Total distance covered by a molecule from the initial point.
  • Total distance covered to the right.
  • Total distance covered to the left.
  • Expected Value of Number of steps towards right.
  • Variance of steps of particles.

Answers (2)

Image Analyst
Image Analyst on 23 Sep 2022
Click on some of the tags and links on the right hand side of this page. Random walk questions get asked very frequently and you can most likely find something. In any event, I'm attaching a variety of random walk demos I've made. Perhaps you'll like one of those. If you have any questions, see this link:

Walter Roberson
Walter Roberson on 23 Sep 2022
Encode a step to the left as binary 0. Encode a step to the right as binary 1. Any particular random walk of N steps can then be encoded as an N-bit binary string. Taking a step to the right followed later by a step to the left gets you to the same location as if you took a step to the left, did the same intermediate actions, then a step to the right, and likewise the same as if you had taken a step to the left then a step to the right and then did the intermediate actions. The order of steps is therefore irrelevant to the final location: all that matters is the difference between the number of steps to the left and the number of steps to the right. The number of steps to the left is N minus the number of steps to the right, so the difference is R - (N-R) = 2*R - N -- if R is more than half of N you end up to the right of the origin and if R is less than half of N you end up to the left of the origin. You can see that the solution is unique for any given R
The probability of exactly R steps is then p^R * (1-p)^(N-R) and that is something you can plot.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!