## SIMULATING FRACTIONAL POISSON TIMES AND TRUNCATED STABLE RANDOM VARIABLES

October 14, 2015 by zulfahmed

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.integrate import quad

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):

I,e=quad(tlf, -np.inf, x, args=(theta))

return I

def qtlf(u,theta):

def obj(t):

return abs(dtlf(t,theta)-u)

res = minimize( obj,0.0, method=”Nelder-Mead”)

return res.x

theta = [1.52, 6.0, 7.0]

v = rtlf( theta[0], theta[1], theta[2], size=100)

print(v)

### Like this:

Like Loading...

*Related*

## Leave a Reply