Simulating random walks
Consider a discrete random walk
where
with
A sample path (with
We can simulate this random walk on a computer, or on Google Sheets in particular, in the following manner.
- Set
; . - Generate a uniformly distributed random number
. - If
, then set , else set . - Increment
, go to Step 2 and repeat.
To generate a uniformly distributed random number , we can use the built-in function RAND() in Google Sheets (as well as in Excel). Similar functions are available in most programming languages.
Such a random number is less than with probability if . This is how to realize an event with a specified probability in general.
Comments
Post a Comment