2019-06-10几何泊松过程模拟

import numpy as np
import matplotlib.pyplot as plt

N = 20
sigma = 0.3
lam = 5
lamb = N
alpha = 0.5
S0 = 10
St = np.zeros(N)
Nt = [n for n in range(1, N + 1)]

t = np.random.exponential(scale=1/lam, size=N)
tt = np.zeros(N)

for i in range(0, N):
    tt[i] = sum(t[:i + 1])

for i in range(N):
    St[i] = S0 * np.exp((alpha - lam*sigma)*tt[i])*(sigma + 1)**Nt[i]
    
    
plt.figure()
plt.grid()
plt.xlabel('t')
plt.ylabel('S(t)')
plt.title('Geometric Poisson process')
plt.plot(tt, St,  'o-', color='r')
plt.show()
1.png

你可能感兴趣的:(2019-06-10几何泊松过程模拟)