Let \(X=(X_i)_{i=1}^{\infty}\) be an iid sequence of random variables. Let \(N\) be a random nonnegative integer that is independent of \(X\). Suppose \(X_1\) and \(N\) have finite expectations. Prove that \[ \mathbb{E} \big( \sum_{i=1} ^N X_i \big) = \mathbb{E}N \mathbb{E} X_1\]
Observe that
\[\sum_{i=1} ^N X_i = \sum_{n=0} ^{\infty}\sum_{i=1} ^n X_i\mathbf{1}[N=n].\]
Note that we take as convention that when \(n=0\), we have the empty sum, which is zero. Since \(N\) and the iid sequence \(X\) are independent, we have that
\[\mathbb{E}(X_i \mathbf{1}[N=n] ) = \mathbb{E}(X_i) \mathbb{E}(\mathbf{1}[N=n] ) = \mathbb{E}(X_i) \mathbb{P}(N=n).\] Thus taking expectations on both sides (and bring the expectation operator over an infinite sum) we have
\[ \mathbb{E} \big( \sum_{i=1} ^N X_i \big) = \sum_{n=0} ^{\infty}\sum_{i=1} ^n \mathbb{E}(X_i) \mathbb{P}(N=n) = \mathbb{E}(X_1)\sum_{n=0}n\mathbb{P}(N=n) = \mathbb{E}(X_1) \mathbb{E}(N),\]
as desired.
How would you do Exercise 4 analytically?
What would you do if there is more than two tiles, and the tiles did not occur with equal probability?
Use simulations to test your formula.
\[\lim_{t \to \infty} \mathbb{P}(\text{that we are on an a-tile at time } t) = \frac{\mathbb{E}( aN_a) }{\mathbb{E}( aN_a) + \mathbb{E}( bN_b) } = \frac{a}{a+b}\]
\[\big( b \cdot \tfrac{p_b}{p_b+p_c} + c \cdot \tfrac{p_c}{p_b+p_c} \big) \cdot \tfrac{1}{p_a}.\]
Thus
\[\lim_{t \to \infty} \mathbb{P}(\text{that we are on an a-tile at time } t) = \frac{\tfrac{a}{1-p_a}} { \tfrac{a}{1-p_a} + (b \cdot \tfrac{p_b}{p_b+p_c} + c \cdot \tfrac{p_c}{p_b+p_c} \big) \cdot \tfrac{1}{p_a} }.\]
import numpy as np
pa= 2/9
pb= 3/9
pc= 4/9
a=1
b=np.sqrt(2)
c=np.pi
def type():
x=a
u=np.random.uniform()
if (u > pa and u < pa+pb):
x=b
if (u > pa+pb):
x=c
return x
def tile(t):
ctile = type()
tlength = ctile
while(t > tlength):
ctile = type()
tlength = tlength + ctile
return ctile
y = [tile(300) for _ in range(1000) ]
freq = np.unique(y,return_counts = True)
print(freq)
## (array([1. , 1.41421356, 3.14159265]), array([ 90, 229, 681], dtype=int64))
tile1 = (1/1000)*freq[1][0]
tile1theory = (a/(1-pa)) / ( a/(1-pa) + (b*(pb/(pb+pc)) +c *(pc/(pb + pc)))*(1/pa) )
print(tile1 - tile1theory )
## -0.016332011180342706
Let \(\Pi\) be a Poisson point process on \([0, \infty)\). Pick a (large) number, say \(x=\sqrt{2} + 100\). Find the smallest interval \((A,B)\) such that \(x \in (A,B)\), and \(A\) and \(B\) are points of \(\Pi\), thus \(B\) is the next arrival after \(A\).
Find the distribution of \(S=B - A\).
Is \(S\) exponentially distributed? Explain.
Do simulations to confirm your findings.
Consider a Poisson process of intensity \(\lambda\)
One can also think about generating a two-sided Poisson process on \((-\infty, -\infty)\), this can be accomplished by putting together two independent Poisson processes on \((0, \infty)\) glued at \(0\), where one is flipped.
We see that \(S\) has actually the sum of two independent exponentials.
We can also see this in the following Python code, where we take \(\lambda\)=1:
# Poisson arrivals just past the end time
def pois(end):
T= np.array([np.random.exponential()])
while(T[-1]<end):
T = np.append(T, T[-1] + np.random.exponential())
return T
def find(times,x):
n=0
while(x > times[n]):
n = n+1
return (times[n] - times[n-1])
print(find(pois(200), 100+np.sqrt(2) ))
## 1.8857454328843772
y = [find(pois(200), 100+np.sqrt(2) ) for _ in range(5000) ]
print(np.mean(y))
## 1.9517397077124503
import matplotlib.pyplot as plt
supress=plt.hist(y, bins = 100, density=True, label='Proability Histogram')
t=np.linspace(0,10,num=1000)
plt.plot(t,t*np.exp(-1*t), label='Exact Density')
plt.legend(loc='upper left')
plt.show()