Python Homework 1¶
Release date: Friday, January 10
Due date: Friday, January 24, 11:59 p.m. via GauchoSpace
Instruction: Please upload your jupyter notebook on GauchoSpace with filename “PythonHW1_YOURPERMNUMBER.ipynb”.
Load some packages:
In [ ]:
import numpy as np
import matplotlib.pyplot as plt
Problem 1 (5 Points)¶
1. Implement the simulation of a Poisson process $(N_t)_{0 \leq t \leq 100}$ with parameter $\lambda = 0.1$ on the time interval $[0,100]$.
In [ ]:
# WRITE YOUR OWN CODE HERE! FEEL FREE TO INSERT MORE CELLS!
# ADD COMMENTS TO YOUR CODE!
1. Plot a trajectory of your simulated process from part 1.
In [ ]:
# WRITE YOUR OWN CODE HERE! FEEL FREE TO INSERT MORE CELLS!
# ADD COMMENTS TO YOUR CODE!
Problem 2 (5 Points)¶
1. Simulate a compound Poisson process $(C_t)_{0 \leq t \leq 30}$ with parameter $\lambda=1/2$ on the time interval $[0,30]$ where the jumps $Y_1, Y_2, \ldots$ are given as random variables
$$ Y_i = e^{Z_i} \qquad (i = 1,2,\ldots)$$
with $Z_1, Z_2, \ldots$ i.i.d. normal distributed random variables with mean 0 and variance 1 (also independent of the underlying Poisson process $(N_t)_{0 \leq t \leq 30}$). Plot a trajectory of your simulated process.
Hint: Use your method from Problem 1 to simulate the underlying Poisson Process $(N_t)_{0 \leq t \leq 30}$ driving the compound Poisson process $(C_t)_{0 \leq t \leq 30}$.
In [ ]:
# WRITE YOUR OWN CODE HERE! FEEL FREE TO INSERT MORE CELLS!
# ADD COMMENTS TO YOUR CODE!
1. Simulate $M=10000$ times the compound Poisson process from part 1 and compute the empricial mean and variance of your samples for the random variable $C_{30}$. Compare your empricial values with the exact theoretical values which are given by
$$\mathbb{E}[C_{30}] = \mathbb{E}[N_{30}] \cdot \mathbb{E}[Y_1] \qquad \text{and} \qquad \text{Var}(C_{30}) = \mathbb{E}[N_{30}] \cdot \mathbb{E}[Y^2_1].$$
Hint: Recall that $$\mathbb{E}[e^{Z_1}] = e^{0.5} \qquad \text{and} \qquad \mathbb{E}[(e^{Z_1})^2] = e^2.$$
In [ ]:
# WRITE YOUR OWN CODE HERE! FEEL FREE TO INSERT MORE CELLS!
# ADD COMMENTS TO YOUR CODE!