MGSC 372 Advanced Business Statistics Lecture 2: Random Walks Javad Nasiry © 2025 McGill University Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 1 / 31 Why study random walks? Review and reinforce several important concepts from MGCR 271 Build up to understanding a commonly used model for stock prices Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 2 / 31 Hopping frogs A frog starts out at 0 on the number line. -2 -1 0 1 2 Every second, it jumps one step left or one step right, with equal probability. Where will the frog be after 100 seconds? Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 3 / 31 Hopping frogs A frog starts out at 0 on the number line. -2 -1 0 1 2 Every second, it jumps one step left or one step right, with equal probability. Where will the frog be after 100 seconds? Could go all the way to 100 or -100 (extremely improbable) Could end up back at 0 (most likely outcome, but still not very likely) Could be somewhere in between Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 3 / 31 A better question: What is a typical outcome for the frog after 100 seconds? Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 4 / 31 A better question: What is a typical outcome for the frog after 100 seconds? To get a handle on this, let’s simulate some frogs on the computer! Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 4 / 31 A better question: What is a typical outcome for the frog after 100 seconds? To get a handle on this, let’s simulate some frogs on the computer! Here is one frog’s path: 12 8 Location 4 0 −4 −8 −12 0 25 50 75 100 Time Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 4 / 31 A better question: What is a typical outcome for the frog after 100 seconds? To get a handle on this, let’s simulate some frogs on the computer! Here is a second frog’s path: 12 8 Location 4 0 −4 −8 −12 0 25 50 75 100 Time Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 5 / 31 A better question: What is a typical outcome for the frog after 100 seconds? To get a handle on this, let’s simulate some frogs on the computer! Here is a third frog’s path: 12 8 Location 4 0 −4 −8 −12 0 25 50 75 100 Time After 100 seconds, these three frogs ended up at 4, 10, and -4. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 6 / 31 Now let’s simulate 10 frogs and record where each one ends up after 100 seconds. The ending positions are: →2, →4, Javad Nasiry →6, 16, 10, →14, MGSC 372 Advanced Business Statistics →2, 0, 4, © 2025 McGill University →28 7 / 31 Now let’s simulate 10 frogs and record where each one ends up after 100 seconds. The ending positions are: →2, →4, →6, 16, 10, →14, →2, 0, 4, →28 This is easier to visualize in a bar chart: 2.0 Count 1.5 1.0 0.5 0.0 −30 −20 −10 0 10 Location of frog after 100 seconds Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 7 / 31 Why not simulate 10,000 frogs! Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 8 / 31 Why not simulate 10,000 frogs! 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 8 / 31 Why not simulate 10,000 frogs! 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds This is an empirical distribution of the ending location of a frog that follows a random walk for 100 seconds. It will be (slightly) di!erent every time we run the simulation. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 8 / 31 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds Let’s use this empirical distribution to address the question: What is a typical outcome for the frog after 100 seconds? Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 9 / 31 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds Let’s use this empirical distribution to address the question: What is a typical outcome for the frog after 100 seconds? As anticipated, 0 was the most likely outcome, but only about 8% of the frogs ended up exactly at 0. All 10000 frogs ended up between -40 and 50. Most frogs ended up between -20 and 20 (to be precise, 9657 out of 10000, or 96.57%) Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 9 / 31 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds We can also compute the summary statistics of the empirical distribution: sample median sample mean sample standard deviation Javad Nasiry 0 →0.049 9.885 MGSC 372 Advanced Business Statistics © 2025 McGill University 10 / 31 800 Count 600 400 200 0 −40 −20 0 20 40 Location of frog after 100 seconds We can also compute the summary statistics of the empirical distribution: sample median sample mean sample standard deviation 0 →0.049 9.885 Because the distribution looks normal and the mean is close to 0, the standard deviation is a good numerical measure of the “typical” displacement of the frog after 100 seconds. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 10 / 31 We’ve considered the case of “binary frogs” (two choices for each step). Let’s now consider two variations: normal frogs and exponential frogs. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 11 / 31 We’ve considered the case of “binary frogs” (two choices for each step). Let’s now consider two variations: normal frogs and exponential frogs. Normal frog: each step is randomly drawn from the standard normal distribution N (0, 1): -2 -1 0 1 2 Standard normal distribution Positive and negative steps are equally likely; the size of most steps is between 0 and 2 Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 11 / 31 Exponential frog: each step is randomly drawn from the (shifted) exponential distribution (with rate 1): 1 -1 0 1 Shifted exponential distribution Small negative steps are most common (the median step size is -0.307), but large positive steps can occur Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 12 / 31 Now we’ll learn how to simulate random walks in Python! Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 13 / 31 Results of the simulations Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 14 / 31 Binary steps Each step comes from the discrete distribution X Prob →1 1 2 1 1 2 Example of a binary random walk with 100 steps: Location 0 −5 −10 0 25 50 75 100 Time Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 15 / 31 Normal steps Each step comes from the standard normal distribution N (0, 1) -2-1 0 1 2 Example of a normal random walk with 100 steps: Location 10 5 0 −5 0 25 50 75 100 Time Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 16 / 31 Shifted exponential steps Each step comes from a shifted version of the exponential distribution with rate 1 1 -1 0 1 Example of a shifted exponential random walk with 100 steps: Location 4 0 −4 0 25 50 75 100 Time Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 17 / 31 Empirical distributions of the endpoints of 10000 simulated random walks, each of 100 steps. Binary 800 Count 600 400 200 0 −40 −20 0 20 40 Location after 100 steps Normal Exponential 1000 900 Count Count 750 500 600 300 250 0 −20 0 20 40 0 −40 Location after 100 steps −20 0 20 40 Location after 100 steps All three distributions look remarkably similar! They all have mean close to 0 and standard deviation close to 10 They all look roughly normal Why are they so similar? Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 18 / 31 Random variables and the theory of the random walk Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 19 / 31 A random variable assigns a number to the outcome of a random process. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 20 / 31 A random variable assigns a number to the outcome of a random process. There are two types of random variables: discrete and continuous. Discrete random variables: The possible values of the random variable are distinct points on the number line We can show the probability of each value in a table (or with a bar graph) Example: Each step taken by the binary frog is a discrete random variable with the following probability distribution: X Prob Javad Nasiry →1 1 2 1 1 2 MGSC 372 Advanced Business Statistics © 2025 McGill University 20 / 31 Continuous random variables The possible values of the random variable make up an interval on the number line The probability distribution is described by a curve called a density function The probability of any particular value occurring is 0 The probability of observing a value in the interval [a, b] is the area under the density function f (x) between a and b: P (a ↑ X ↑ b) = ! b f (x) dx a Example: Each step taken by a normal or exponential frog is a continuous random variable. We saw the density functions earlier in the lecture. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 21 / 31 Three parameters associated to a random variable The expected value or mean of a random variable X is denoted E(X) or µX . For discrete r.v.’s, it is defined by " E(X) = xi · Prob(xi ) where x1 , x2 , . . . are the values that X can take, and Prob(xi ) is the probability of the value xi occurring. (For continuous r.v.’s, the expected value is defined using integrals—you won’t be asked to use this definition.) Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 22 / 31 Three parameters associated to a random variable The expected value or mean of a random variable X is denoted E(X) or µX . For discrete r.v.’s, it is defined by " E(X) = xi · Prob(xi ) where x1 , x2 , . . . are the values that X can take, and Prob(xi ) is the probability of the value xi occurring. (For continuous r.v.’s, the expected value is defined using integrals—you won’t be asked to use this definition.) The variance of X is denoted var(X) or ω 2 (X). For discrete r.v.’s, it is defined by " var(X) = (xi → E(X))2 · Prob(xi ) The standard deviation of X is denoted sd(X) or ω(X), and is defined by # sd(X) = var(X) Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 22 / 31 Back to random walks -2 -1 0 1 2 Definition A random walk is a random process that starts at 0 and consists of repeated steps along the number line, where each step is independent of the previous steps each step is drawn from the distribution of a fixed random variable X In other words, the steps are independent and identically distributed (i.i.d) copies of a fixed random variable X. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 23 / 31 Theory of the random walk Consider a random walk of n steps, where each step is drawn from the distribution of a fixed random variable X. The endpoint of this walk is the random variable X1 + X2 + . . . + Xn where the Xi are i.i.d. copies of X. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 24 / 31 Theory of the random walk Consider a random walk of n steps, where each step is drawn from the distribution of a fixed random variable X. The endpoint of this walk is the random variable X1 + X2 + . . . + Xn where the Xi are i.i.d. copies of X. How do we express the mean, standard deviation, and variance of this sum in terms of the parameters of X? Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 24 / 31 Theory of the random walk Consider a random walk of n steps, where each step is drawn from the distribution of a fixed random variable X. The endpoint of this walk is the random variable X1 + X2 + . . . + Xn where the Xi are i.i.d. copies of X. How do we express the mean, standard deviation, and variance of this sum in terms of the parameters of X? We need to recall the “rules for expected values and variances”... Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 24 / 31 As explained on the board, we end up with the following formulas: If X1 , . . . , Xn are i.i.d. copies of a fixed random variable X, then E(X1 + X2 + · · · + Xn ) = n · E(X) and sd(X1 + X2 + · · · + Xn ) = Javad Nasiry ↓ n · sd(X) MGSC 372 Advanced Business Statistics © 2025 McGill University 25 / 31 As explained on the board, we end up with the following formulas: If X1 , . . . , Xn are i.i.d. copies of a fixed random variable X, then E(X1 + X2 + · · · + Xn ) = n · E(X) and sd(X1 + X2 + · · · + Xn ) = ↓ n · sd(X) The above formulas come from a simple application of the rules for expected values and variances. The following fact is much deeper: As n gets larger, the distribution of X1 + · · · + Xn gets closer and ↓ closer to a normal distribution (with mean n · E(x) and standard deviation n · sd(X)) This is the version of the Central Limit Theorem for sums (do you see how it is related to the version for averages that you learned in MGCR 271)? Unless otherwise specified, we will consider the approximation safe to use when n > 25. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 25 / 31 For the three types of random walks we considered: E(X) = 0 sd(X) = 1 where X is the distribution of a single step Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 26 / 31 For the three types of random walks we considered: E(X) = 0 sd(X) = 1 where X is the distribution of a single step Thus, in all three cases, the location of a random walk after 100 steps has expected value: 100 · E(X) = 100 · 0 = 0 ↓ standard deviation: 100 · sd(X) = 10 · 1 = 10 Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 26 / 31 For the three types of random walks we considered: E(X) = 0 sd(X) = 1 where X is the distribution of a single step Thus, in all three cases, the location of a random walk after 100 steps has expected value: 100 · E(X) = 100 · 0 = 0 ↓ standard deviation: 100 · sd(X) = 10 · 1 = 10 Moreover, n = 100 is large enough that the Central Limit Theorem gives a very good approximation. This explains the similarity of the three empirical distributions! (Important note: when each step X is drawn from a normal distribution, X1 + · · · + Xn is normally distributed for EVERY n. There is no need to appeal to the Central Limit Theorem in this case.) Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 26 / 31 Random walks with drift If E(X) ↔= 0, the random walk tends to drift in the positive or negative direction, depending on the sign of E(X). Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 27 / 31 Random walks with drift If E(X) ↔= 0, the random walk tends to drift in the positive or negative direction, depending on the sign of E(X). For example, here are three random walks with steps X drawn from N (0.5, 2): Random walks with drift Location 60 40 20 0 0 25 50 75 100 Time n The expected value of the location after n steps is n · E(X) = . This is shown 2 by the dashed line. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 27 / 31 Using the Central Limit Theorem Exercise (solution in appendix): The time it takes for a certain grocery store clerk to check out a customer follows an exponential distribution with a rate of 0.5 customers per minute. That is, the checkout time has the distribution 0.5 1 f (x) = 12 e→ 2 x 0 (Var = 4 = 36*4 12=sqrt(36*4)) N(2, 12) where x is measured in minutes. The expected value of this distribution is 2 minutes, and the standard deviation is also 2 minutes. 1 What is the expected time for this clerk to check out 36 customers?72 mins 2 What is the probability that it will take more than 90 minutes for the clerk to check out 36 customers? =1.5 stds, z-table: 6% 3 How much time must the clerk allow in order to have a 99% chance of checking out all 36 customers? 2.33 stds away, = 99.96 mins 4 Give a 90% prediction interval for the amount of time it will take the clerk to check out 36 customers. That is, give an interval that has a 90% chance of containing the actual amount of time it takes to check out 36 customers. Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 28 / 31 5% 90% 5% 1.64 stds away so +-19.68mins from 72 52.32-91.68 mins A random walk in two dimensions 40 30 20 10 0 −10 0 Javad Nasiry 10 20 30 MGSC 372 Advanced Business Statistics 40 50 © 2025 McGill University 29 / 31 Appendix: solution to the exercise Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 30 / 31 1 E(X1 + . . . + X36 ) = 36 · E(one customer) = 72 2 By the CLT, X1 + . . . + X →36 is approximately normal. The mean is 72, and the standard deviation is 36 · sd(one customer) = 12. So ! " 90 ↑ 72 P (X1 + . . . + X36 > 90) = P Z > 12 = P (Z > 1.5) = 1 ↑ 0.9332 = 0.0668 3 The z-score with 99% of the area to its left is approximately 2.33. Thus, the clerk must allow 2.33 ↓ 12 + 72 ↔ 100 minutes 4 The z-score with 5% of the area to its right is 1.645. So a 90% prediction interval is [↑1.645 ↓ 12 + 72, 1.645 ↓ 12 + 72] ↔ [52.3, 91.7] minutes Javad Nasiry MGSC 372 Advanced Business Statistics © 2025 McGill University 31 / 31
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )