Feeds:
Posts

## SIMULATING FRACTIONAL POISSON TIMES AND TRUNCATED STABLE RANDOM VARIABLES

Volatility in financial markets can be modeled by fractional Poisson time events with jump sizes from truncated stable random variables.  Cahoy et. al. solved the problem of simulating fractional Poisson times (cahoy-parameter-estim-fpp) while Kanter (1975) and Chambers-Mallows-Stuck (1976) solved the problem of simulating stable random variables (see weron-chambers-mallows-stuck-stable-sim for formal proofs).  For truncated Levy stable variables, a simple solution we implement which is probably well-known in finance is rejection sampling.  The implementation is here.

import numpy as np
from stablemix import *
from scipy.optimize import minimize
def rstable(alpha,zeta, beta=0, size=1):
Sab = (1+beta*beta*(np.tan(np.pi*alpha/2))**2)**((1-alpha)/alpha)
Bab = (1/alpha)*np.arctan(beta*np.tan(np.pi*alpha/2))
V = np.random.uniform(low=-np.pi/2,high=np.pi/2,size=size)
W = np.random.exponential(size=size)
A = (np.cos(V-alpha*(V-Bab))/W)**((1-alpha)/alpha)
B = Sab*np.multiply(np.sin(alpha*(V+Bab)), 1.0/np.cos(V)**(1/alpha))
return A*B
def rtlf(alpha,zeta,l=10.0,size=1):

res = np.zeros((size,))

for k in range(size):
accept = False
while accept is False:
s = rstable(alpha,zeta,size=1)
u = np.random.uniform(size=1)
if u < np.exp(-l*s):
accept = True
res[k] = s
return res
def dtlf(x,theta):