Homework 10

Due Tue, May 7, 11:59pm

Download the .ipynb file for this notebook, and place your solutions where indicated (you can make more cells for each problem), keeping the original problem descriptions. Upload only one file, which contains all your work; it should be named "HW10_firstname_lastname". Please include comments in your code; this can also help you get partial credit if your code doesn't work.

Then upload it to Blackboard under the Assignments tab. See Collaboration Policy in Homework section of course webpage (it's the same as it was for previous homeworks).

Problem 1

Recall that the rand_walk_improved function we wrote in class (04/16) generates a random walk where each vertical step moves up/down vert_size*rand, where rand is either $1,-1$ each with probability $1/2$. Modify this function so that rand is a (standard) normal random variable. Test this function with the number of steps large. How does this new random walk compare to the one we studied in class?

In [1]:
# Your solution goes here

Problem 2

Write a function prob_return(n) that estimates the probability that a random walk of length $n$ (with steps of size $1,-1$, each with probability $1/2$) hits the $x$-axis at some time other than just at its start. To estimate this probability, you should generate many random walks of length $n$, and count how many of them return. Estimate the probability for $n=5,10,100$.

In [2]:
# Your solution goes here

Problem 3

Modify the random walk from class so that instead of the step size being fixed, it is proportional to the current height. That is if the height at time $i$ is $h$, then at time $i+1$, it is either $h*(1-s)$ or $h*(1+s)$, each with probability $1/2$. Start the random walk at some height quite far away from $0$ (since it will get "stuck" at $0$). Test it with a large number of steps.

(This is often taken to be a model of stock prices, since if say $s=0.01$, it could model a stock whose price increases or decreases by 1% every day, each with probability $1/2$. This is more realistic than modelling with the basic random walk, which would say that every day it either loses or gains $1 every day, regardless of the current price).

In [3]:
# Your solution goes here

Problem 4

Empirically demonstrate the Central Limit Theorem for independent Poisson random variables. That is, sample sums $$\frac{(X_1-\lambda) + \cdots + (X_n-\lambda)}{\sqrt{n}},$$ where each $X_i$ is an instance Poisson random variable (use intensity $\lambda=1$). Repeat this many times and draw a histogram of the results. It should look like a normal distribution.

In [ ]:
# Your solution goes here