See the code in Example 9.13 for generating a simple random walk. Write a function for simulating a biased random walk where the probability of moving left and right is p and 1 - p, respectively. Graph your function obtaining pictures like Figure 9.8. What do you notice about the behavior of the random walk when p = 0.60, 0.55, 0.505?
Example 9.13
Random walk. Random walks are fundamental models in physics, ecology, and numerous fields. They have been popularized in finance with applications to the stock market. A particle starts at the origin on the integer number line. At each step, the particle moves left or right with probability 1/2. Find the expectation and standard deviation of the distance of the walk from the origin after n steps.