Skip to content
Snippets Groups Projects
Commit cf1e70b4 authored by Ulrich Kerzel's avatar Ulrich Kerzel
Browse files

Exercise skeleton for random walk

parent 9afc87e1
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Random walk in two dimensions
A random walk is a sequence where decide randomly in which direction we can move. For example, in a one-dimensional random walk, we decide randomly if we move left or right.
We could take a coin, toss it and move right if it shows "head", or left if it shows "tail".
Similarly, in a two-dimensional random walk, we need to decide if we move up, down, left, or right.
In the simplest case, we aways take steps of the same length, but we could also vary our step size and take short, medium, or long steps.
### Exercise:
* Write a program that contains a function to create data from a 2D random walk where we take 100 steps.
* Let each random walk start at (0,0), i.e., the first pair of values is $x=0, y=0$.
* Make the step size an optional parameter, the step size is fixed for a complete random walk.
* Hint: Think about what the function should return.
* Plot multiple random walks on top of each other. \
* Calculate the distance of between the start and the end of each random walk. \
* For 200 random walks, create a histogram of the distribution of the distance.
*Hint*: \
Think about which modules can help you so that your code is efficient and fast.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment