2D Random Walk Using R
Random Walk using R
This is an example of creating a Random walk using R programming. Here we have tried to build a data frame that consists of the steps taken in the walk. These steps are generated based on a condition that is in turn dependent upon a random value picked up from a sample space.
This code follows these instructions:
- Initiating the initial steps
- If the random value of dice thrown is satisfying a condition ( say <= 4 or >= 3) then we mode if forward which is +1 else backward -1
- This is iterated over and over again until the loop reaches its maximum limit.
- Plotting the final positions of the is the graph generated which is also called as "2D Random Walk"