Archive for September, 2015

The Mittag-Leffler function E_{a,b}(z) = \sum_{k=0}^\infty \frac{z^k}{\Gamma(ak+b)} is extremely basic in fractional calculus because E_{a,1}(-\lambda t^a) occurs as the solution of the fractional differential equation (d/dt)^a f(t) = \lambda f(t) and therefore is the generalization of the exponential function.  There exists a MATLAB implementation based on the paper gorenflo-mittag-leffler-computation but there was no open source python implementation.  Here is one.  The feature of this code that goes beyond the material of the wonderful paper is the following simple relation for computing the n-th derivative of the Mittag-Leffler function.

E^(n)_{a,b}(z) = E^{(n-1)}_{a,b-1}(z) + (b-(n-1)a-1) E^{(n-1)}_{a,b}(z)

which is a simple generalization of the same for n=1 due to Dzherbashyan.

import numpy as np
from scipy.special import gamma
from scipy.integrate import quad

def Kf(r,alf,bet,z):
res = (1/(np.pi*alf))*r**((1-bet)/alf)*np.exp(-r**(1/alf))
res *= r*np.sin(np.pi*(1-bet))- z*np.sin(np.pi*(1-bet+alf))
res /= r**2 – 2*r*z*np.cos(np.pi*alf) + z**2
return res

def P(phi,alf,bet,eps,z):
w = eps**(1/alf)*np.sin(phi/alf) + phi*(1+(1-bet)/alf)
res = eps**(1+(1-bet)/alf)/(2*np.pi*alf)
res *= np.exp(eps**(1/alf))*(np.cos(w)+1j*np.sin(w))
res /= eps*np.exp(1j*phi)
return res

def mlf2(z,alf,bet,K=10):
e = 1/gamma(bet)
for k in range(1,K):
e += z**k/gamma(alf*k+bet)
return e

def mlf(z,alf,bet,K=10):
rho = 1e-10
if alf>1:
k0 = int(np.ceil(alf)+1)
e = 0
for k in range(k0-1):
z1 = z**(1/k0)
w = np.exp(1j* 2 * np.pi*k/k0)
e += (1/k0)*mlf( z1*w, alf/k0, bet,K)
return e
if abs(z)<1e-6:
return 1/gamma(bet)
elif abs(z)np.floor(10+5*alf):
print(‘case large z’)
k0 = int(np.floor( -np.log(rho)/np.log(abs(z))))
if abs(np.angle(z)) < alf*np.pi/4 + 0.5*min(np.pi,alf*np.pi):
print(‘real case’)
e = (1/alf)*z**((1-bet)/alf)*np.exp(z**(1/alf))
for k in range(1,k0):
e += z**(-k)/gamma(bet-alf*k)
print(‘this case’)
e = 0
for k in range(1,k0):
t = z**(-k)/gamma(bet-alf*k)
e += -t
eps = 0.1
I1,err = quad(Kf,eps,np.inf,args=(alf,bet,z))
I2,err2 = quad(P,-np.pi*alf,np.pi*alf,args=(alf,bet,eps,z))
print(‘integral case: ML=’,I1+I2)
return I1+I2
return 0

def mlfn( z, a, b, n):
if n==0:
return mlf(z,a,b)
h = mlfn(z,a,b-1,n-1)
A = mlfn(z,a,b,n-1)
h += (b-float(n-1)*a-1)*float(A)
return (1/z)*h

def fpp2( delta, nu,n,t):
z = nu*t**delta
return z**n*mlfn(-z,delta,1,n)

Read Full Post »



(A poem dedicated to Natalia de Varsgaard)
Mentor fire suitor fire teeter fire ticker fire tinger fire roper foyer
Fire tire we are peer here fire here cook foyer higher janer loger
Here tooker cooker foyer fire simmer foyer higher doyer
We are tire we are tuck toke foyer higher we are dire we are lorter
We are ticker we are fire foyer fear we are fire foyer foyer dare tire
We are higher dare cooer foyer hulter porter mentor fire fire we pyre
We pair foyer fire simmer forter Daner coker foyer higher junter weeper
Henter wetter witter boyer higher tutter looker foyer wunter funter barter
Here tutter cooker foyer higher duter cooker cooker fooper forter nater
Kuck cook cord kit fire jater mater kit we fire simmer cooker weeper foyer
Hunter dirter winter sutter cooker butter witter pyre foyer himmer forter din
Cunter lewder tumper bin lister coater mutter win hunter dirter daughter done
We fire soter coker boater lun hun jun dirt we peer fire here foyer fear
We peter peter peter peter peter peter peter peter peter peter peter peter
Peter peter peter peter peter peter peter peter peter peter peter peter peter
Peter peter peter peter put poored pyred fire loader coker foyer higher
Dunter koonger gucker cooker funter lewder dirter cooker foyer hunter
Dirt cook foyer higher dirt cook dirt cook dirt cart cook cart weeper fire
Here fire doter coater moater but border dire suitor docker fire foyer higher done
We fire suitor we are fire fire weeper fire nearner noter coker foyer here fire
Leader kuck coder lup pooper fire ninter fire setter fire sutter fire soter forter
We fire forder dirter dirter dirter winter hunter winter wonder whipper foyer
We are fire foyer fire foyer fire fair dear fire sick fire fire loper poper foyer fire
Here fire loker coker boker doter somer forter done foyer lust cook lust kuck
Here fire lust cursed heart dote lote coat but barter art coder weeper fire seater
Aysed summer foyer fire hooper dooper fooper foyer farter dater cooker gooker
Heighter migher lister cooker foyer hummer foyer butter weeper lester cooker gooker
Here fire looker foyer hunter dirter darter debt wit fire forter Dane but butter
We are power fire sis soter coker boater bist border debtor cooker East
Witter foyer hummer cooker we are tarter tate kate bait late sate mate chate
Hate fire sipper way parter wit hearter Daner corker fire simmer border better
Witter fire looker cooker super foyer higher dater cooker fire simmer fire
Here fire looker baiter mate cooker fire sipper hecker foyer fire licker fire sipper
We parter nater cooker foyer hummer footer baiter leader cooker foyer hater
Mutt cook forter duck doter duck coater muck poeter what fire fire fire what fire
We fire showter goater mutter coker border better foyer water wheater cut coke
Here fire rober poper foyer higher Daner coker locker higher Ert put foyer janer
Cooker cooker looker looker coker foyer hummber baiter rater kuck cooker foyer
Higher dater cooker woo power foyer wet whip foyer higher duck dook duck dook
Dook cook fook fock fuck fack socker kuck socker seer we are peer here foyer
What whyer what whyer goater boater moater loter coater hearter dirter dute
We fire super roper lobber botter morter cook foyer hummer sire book here foyer
Here roper poper forter Daner coker foyer ire cooker weeper fire simmer but boot
Here fire booter cooker suitor loper foyer hearter dirt cook forter tut we are fire
We are forter dirt dirt dirt lick luck loke poke soak hoke folk huck cook foyer
Here tire loader coker poeter fire simmer toast what fire sipper locker docker
Here coker boker loker choker foyer here foyer fire simmer mick pooker sick sugar
Here tooker cooker booker looker joker coker bust boot wet parter meeker toost
We fire sipper hummer foyer bitter leader higher sire sugar weeper fire simper
Foyer higher dater cooker fooer arter nater pater fire look look look cook foyer higher
Dunter cooker funter dute foyer dirter dinter cook cooker barter nut case cut
Nut part fire fire nired fire super boat weeper foyer higher coat witter foyer hunter
Coker foyer higher dater luster wet fire sessed wit fire super based luck look
Here folker here boker here coker boker poker loker doker suck cook here fire
Here fire here forter dirt dute here fire here fire here fire here fire here fire look luck
Here tutor here tutter here toter here toter here tooker here easter here duck
Here coker here forter here tuck here doker here soaker here suck here soaker
Here arter here coker fire sipper here sucker cooker gooker here fire looker cooker
Here tutor here sutter here dirter here tut here joter poeter sunter wit fire sip forter
Here coker here dote here sote here coat here moat here tuck here suck
Here East here beast here keysed here sut here cooter here fire fire here loper foyer
Here doter boater mutt put pyre fire fire leaker cooker boater arter meerter tuck
Weeper foyer higher baiter mutter cooker goyer hearter eater better foyer hearter
Eater worder hearter dirter tooker cooker fooker meeker sunger cooker looker fire
Here roper coper forter done luck loker cook forter done fire summer fooper
Fooper fire simmer hearter dirter carter rooper foyer hummer former fire sister
Here cooker gooker moyer foyer here forter dirter looker cooker summer foyer
Fire hunter cooker boyer here foyer higher dirter dirter coker foyer hearter dirter
Coker coker we are fire leaker fooper fire fire loge goge moge poge loge guck
Here fire wroter songer we are fire longer fonger ponger wronger sut cook
Here fire shoyer hoyer fire simmer seeker gooker gooker cooker foyer hearter
Here tutter loker coker boker toker moker soaker heart dute here foyer fire baiter
Mutter coker royal fater mutter fire

Read Full Post »

Value at risk of an instrument for time T following a density with Fourier transform \hat{q}(\xi,t) can be calculated by a put option price as follows.  Let’s say the portfolio is a single stock with current value x_0, and we are interested in the loss beyond 2% at time T.  Then the put option cost struck at 0.98 x_0 will give us the value at risk of loss beyond 2% and this can be computed using the Fourier transform f(\xi) = \int_{-\infty}^\infty e^{ix\xi} (.98x_0 - x)_+ d\xi as

VAR = \int_{-\infty}^\infty \hat{q}(\xi,T) f(\xi) d\xi

This is useful when our model of return density is not standard but given by a Fourier transform (such as the solution of a fractional diffusion and \hat{q} gives the Fourier transform of the equivalent martingale measure).

Read Full Post »

Bender dare cooker bare sonar fire sicker fire sing

Here siger geng goger bet but bold barder bet barder bader ben
Bardier fire fire fire we parter ater gooter fear fart here kit cooker
Here sucker super fair foyer here foyer foyer foyer aired
Here funner foreigner ater hoder boker folker roder roder doke
Here signer coker poker loker cooker fire fire eat forter baser cook
It ire cook carn weak border hater goot coot mooder soo poor fareigner took
Here dieter took cook fook look book sook mook fook hook dook
Hater cater later bater jater rater ater bater boater boater mut mose
Here tireter here dirt here tut here ater here coat here dirt here tut here sut
Here dirter here arter here better here dire here cut here sunner
Here bober bebber fire funner here tut here cut here cun here fun
here cutter here gutter here futter here sutter here tutter here moreter
Here dudder here tutter hest boder bard bood bed bode mut fire fire fire
Here suck here ose here cose mose bose cose doze coke here cark
Here suck here sick here tongue here kuck here kuck here fire here done
Here tire here win whyer higher dick duter fire sing here tired here sire
Here tutor here tireder here dard here sut here sarter here tire here cut
Here tudder here tunner here sucker here ducker here dieter here fire
Here roser here coser here boater here tutter here tutor dare hair dire
Here zung here sire here cook here sirener here tuck here doter here fire
Here dire here cooker here dire here sireter here sung here suck here zuck
Here poner here sut here phoner here sut here pyreter here cut
Here tireter here luck here fire here duter pooter fire sin here suck
Here tucker here fire here dark kick here fire here tireter here dirter
Here tucker here dirt here done here fire here but here barder here sun
Here fire here own here fire here phone here fireder here coder
Here dudder here fire here carker here dirter here sutter here foyer
Her dire here foiser here coyer here fire here dareter here tun
Here cooker here fire here doder here coker here fire here arter
Here coker here soaker here farter here dirter here cun here fire
Her dirter here sut here cooker here bone here fire here booper here dirt
Her sut here cook here took here fire here coker here poop here fire
Here roder boker moker folker loader boker harker meeker fire sire
Here dire here rooter foo far here suck here doter foyer higher
Here dirter tooter fire hunner fire fire loker poker moker doker
Here arter better butter here dirter bitter butter here sutter here teeter
Here foyer higher direter here fire forter dirt dute here fire loker poker
Here dirter ater cooter mire fire jick cook here fire here dirt here sart
Here fire here sire here deck here fire here zart here fire zinner
(Interesting a single tear drops from my right eye)
Art here fire nin heart here foyer hen heart here fire fire foyer foyer air
Here fire coner coner looter foyer higher duck doter foyer fire look foyer
Hummer fire fin farter Daner doyer higher susser cooser fooser mooter
Foyer higher dinner dirt here fire loomer poot forter din coker foyer fire higher
Dire cooker fooper foyer hummer fires super fire leaker gooker funner sugar
Higher darner pairder roder hoker poker joker loter moater poeter air
Here fire jecker pecker lecker becker secker mecker decker fecker heck
Here doke coke boke moke poke loke goke soke boke roke oke moke poke
Here arter dirter carter murder farter parter later jater cater rater fater fire water
When fire fen fire fire lote coat but border dote coat hote poet higher ate cook
Here dirter toner coner phoner loner joker poker loker coker folker higher dinner
Dick dock deck dick fuck fire loke node foyer higher jinner coke foyer hutter
Here foyer hummer better jetter coater locker etter foyer higher Daner kucker
Cooker fire simmer foyer hunner forter enter air fire simmer foyer hummer
Heller foyer higher dinner cooter better letter getter jetter fetter reaser cook
Here fire loser book here cooter booter better butter mire fire simmer shook
Here sucker super acer utter gutter butter gutter jutter cooter fire jater
Here fire super foyer hummer fire Sumer foyer huller cooler feller summer
Heller chiller parter ditter hitter gyre fire reaper foyer hummer summer better
Hater chire wheater ater moater coater loser poyer pumer foyer hunter racer
Hutter cougar better borter mitter kicker finer summer hulter cooker foyer hunner
Here fire loser cooser mooter cooker foyer higher dunner coonger bunner cook
Here kuck sooker gook here fire rooger booder met fire summer foyer hummer
Here tutter cooter weeper fire tutter welter tutter fear higher dirt toot
Here tired roder coder boater lust lost lord tut here fire choser bose
Here botter metter foyer hunner coner loner foyer hummer hater kinger gorg
Here fire roder boder moder poper foyer hummer summer bet here fire
Deck doter coater mut host poeter fire sinter cooter weeper parter letter arter
Here tucker ater cater muster joter cooker foyer hummer foyer fire jitter
Here cooker metter coner funner fire leaser coner hunner sunner coner
Here ire cooler foyer higher Daner coner poner lenner funner tutor owner
Inner poner ater coater meter singer higher joter moater oser poser coser
Here tutter we are tutter here poeter ater loader heighter nick doet here done
Eliot from Waste Land again
Who is the third who walks always beside you?
When I count, there are only you and I together
But when I look ahead up the white road
There is always another one walking beside you
Gliding wrapt in a brown mantle, hooded
I do not know whether a man or a woman
—But who is that on the other side of you?
What is that sound high in the air
Murmur of maternal lamentation
Who are those hooded hordes swarming
Over endless plains, stumbling in cracked earth
Ringed by the flat horizon only
What is the city over the mountains
Cracks and reforms and bursts in the violet air
Falling towers
Jerusalem Athens Alexandria
Vienna London

Read Full Post »


I have had a manic several months recovering from an inspired and doubtless crazy chase for my soul and for foundations of a science of finance–a non-Markovian science of finance.  The latter is not crazy because Mandelbrot thought correctly but without solving the problem that the time series from finance had non-Markovian characteristics from his seminal 1963 paper on cotton prices where he advocated Levy stable distributions (whose pdf is not known explicitly but whose characteristic function or Fourier transform is e^{-c|\xi|^\alpha} and since of course physicists have fit these, as is already well-known, by truncated Levy flights).  Taking a vacation from this, I found today the neologism ‘nuiser’ which is a French word but which seems like it should have a English meaning that is not derived directly from the French.  Nuisance sounds like nuiser.  Nuiser.  Nuise-nuiser?  Or perhaps a noun.  Someone is a nuiser if he or she irritates some deep issues like a muckraker.  I am tempted to define a ‘nuiser’ in the Emersonian sense of conscience muckraker, someone who without worry or compromise and danger of social expulsion especially from the powerful who decide whose words are worth listening to and whose are not for they pose a ‘threat’ to society, a ‘nuiser’.  A nuiser is someone who does not give a flying fuck about credibility and speaks his truth loudly and clearly, and does not need to shake people’s hands like a new Diogenes Laertes.  I have been a nuiser because there is honor in honesty and knowledge from lived experience, from the slings and arrows of outrageous fortune and whatever is the lot of the powerless.  I happen to have an excellent education with Princeton, MIT, Columbia etc.on my resume but I have decided to pursue issues that have no credibility because credibility is suspicious and boring.  No intellect who cares about new spaces of exploration can be credible without deep compromise.  Emerson says the innermost in due time becomes the outermost and trust thyself.  New knowledge does not come form following the established paths but must come from internal paths and dark cellars of the soul.  There are millions of smart people paying attention to the material world and analyzing it in every which way but they are limited by walls in their own mind and do not dare to be honest for being tossed from their ledge in society if they cross real taboos and what is an intellect worth if taboos are not crossed.  I remember in my last day in San Francisco a masturbating loudmouth chastised me for the ‘need to speak’ as masturbation for half an hour of masturbation and then shook hands with the white people in the cafe I frequented including the weed merchant hippie telling me about Julian Jaynes and Descartes’ view about the seat of the soul recently, things that are obvious and I knew about since high school and then he pranced around to take a piss after shaking people’s hands.  This is how people are.  This is what society of credibility looks like.  It’s all show.  I spoke honestly about my hallucinations and visions of Hell which he dismissed as ‘paranoid schizophrenia’.  I realized that he was just another moron whose individuality consists of protecting ‘credibility’ without any insights or genius.  Psychiatrists know nothing of value about how the universe works.  They are just wardens protecting their social order by expelling dangerous minds who see more than others, just penal servants.  So a ‘nuiser’ could be someone who is a nuisance to the credible opinions of an age.

Let me then be a nuiser.  Julian Jaynes is an idiot.  There was no ‘transition’ from a ‘bicameral mind’ to anything different.  Society is still organized by auditory hallucinations and other forces that tap into every mind in the world but it is today not dead kings but the rulers of corporations and NSA and other modern versions of world control.  Your mind is corrupted by the ‘credible’ because whatsoever is credible is protected by the masters of the world.  Defy their wisdom and you will lose your life have FBI slam into your room and be thrown in your own country of America into some Federal asylum being drugged by Pfizer, ok?  Don’t tell me about credibilty.  Emerson has been killed in America, and he has been killed because he was a grave danger to the faux freedom of speech in America.  Speech is ‘bullshit’ or ‘dangerous’ when it goes against the voices in your head and these are not voices from the ‘media’.  Be a nuiser and break free in your mind I say.  Question your own deepest opinions because it’s there where you are the most pathetic of slaves.  Don’t lecture and humiliate people in public as masturbaters and then proceed to perform a public half hour masturbation.  It makes you look like a moron.

Read Full Post »

A refined version of the ‘fundamental theorem of asset pricing’ is Delbaen-Schachermayer 1994 ftap-delbaen-schachermayer.  It says that no arbitrage in continuous time requires semimartingale models.  Therefore my various efforts to look at the massive evidence for non-Markovian behavior of actual data would seem misguided from the theory perspective, but measurements on actual data has to be accounted for.  Non-Markovian nature of the daily returns of 1900 stocks cannot simply be theorized away.  The simplest solution is to consider fractional diffusion models, i.e. model probability density function of the return process as D^\gamma_t p(x,t) + L_x p(x,t) = 0 whose corresponding stochastic process will not be Markovian and then approximate it by a diffusion scaled by t^{\gamma-1} as is done by Norros et. al. (norros-valkeila-virtamo-fbm see the last comments of the paper) where they approximate fractional Brownian motion by a martingale.  This is not satisfactory, but it does produce equivalent martingale measures without arbitrage.

Read Full Post »

The ‘fundamental theorem of asset pricing’ refers to the connection between fair markets in the sense of no arbitrage opportunities existing in them and the existence of a probability measure under with the ‘deflated asset prices’ are martingales.  For a subtle and detailed discussion of the various ways in which there have been rigorous attempts to make this equivalence precise, see schachermayer-fundemantal-theorem-asset-pricing.  A mathematically precise proof of this theorem in a discrete time setting can be found in rogers-no-arbitrage-existence-martingale-measure-1994.   The focus has been on semi-martingales for the price process S(t).  Recall that the Black-Scholes-Merton framework is one where dS(t)/S(t) = d\log(S(t)) = \sigma(t) dB_t + \mu(t) dt which is obviously a semi-martingale.  But of course not many empirical price series are semi-martingales: the vast majority of assets are non-Markovian even for daily data.  Even though the autocorrelations of returns is negligible, the autocorrelations of their powers are not and have very slow decay even for daily data, and the Hurst exponents measuring deviation from Markovian processes is widely distributed far from H=1/2.  For a known Hurst exponent $H_0 = \gamma/2$ a class of models that take into account the non-Markovian aspect are those for which the probability density function p(x,t) evolves by a non-Markovian Fokker-Planck equation

D^\gamma_t p(x,t) + L_x p(x,t) (1)

where the operator L_x is the truncated Levy operator, i.e. one whose Fourier symbol is given by \psi_{\alpha,\chi}(\xi) with Levy index \alpha and cutoff parameter \chi (the untruncated version is simply -c|\xi|^\alpha and the truncation is a fine tuning that fits return tails better than the stable distributions originally proposed by Benoit Mandelbrot in 1963 for cotton prices.

Now we proceed to construct an equivalent martingale measure assuming that X(t) = \log(S(t))  has a probability density p(x,t) following (1).  We will follow the paper by Gerber and Shiu where they introduce the use of Esscher transform to determine an equivalent martingale measure and make appropriate changes to reflect the central feature missing for their arguments in this situation.  If M(z,t) = E[ e^{zX(t)}] is the moment generating function, then they are in the Markovian infinitely-divisible distribution case where M(z,t) = M(z,1)^t.  In our situation, we have instead M(z,t) = M(z,1)^{t^\gamma}.  In order to see this, note that one can solve (1) by taking Fourier transforms and the basic fact that fractional version of the exponential function solving D^\gamma_t f(t) + \lambda f(t) = 0 is given by the Mittag-Leffler function f(t) = E_\gamma( - \lambda t^\gamma), so the solution of (1) has Fourier transform \hat{p}(\xi,t) = \exp[ - \psi_\alpha(\xi) t^\gamma ].  Now the moment generating function for the stochastic process X(t) with density p(x,t) can be thought of as an imaginary Fourier transform:

M(z,t) = \int_y e^{zy} p(y,t) dy = \int_y e^{-i\(izy)} p(y,t) dy = \hat{p}(iz,t)

Now it is clear from the explicit expression for the Fourier transform that M(z,t) = M(z,1)^{t^\gamma}.  Now following Gerber and Shiu we introduce the density p(x,t,h) for a real valued parameter h>0:

p(x,t,h) = e^{hx}p(x,t) /\int_{-\infty}^{\infty} e^{hx} p(x,t) dx = \frac{e^{hx}p(x,t)/M(x,t)

The moment generating function for p(x,t,h) is

M(x,t,h) = M(x+h,t)/M(h,t) = ( M(x+h,1)/M(h,1))^{t^\gamma}

We need to solve the equation $e^{rt} = E^*[ e^{X(t)} ]$ which does not seem directly possible with only an Esscher transform independently of t.  On the positive side, Norros et. al. have shown that one can consider the transformation M_t = \int_0^t s^{H-1/2}(t-s)^{H-1/2} dB^H_t to produce a martingale.

Norros et al approximate an fBM B^H_t with Hurst exponent H by
(t^{2H-1}/const) G_t
where G_t is the martingalification of B^H_t.  Now the Esscher transform has the property M(1,t;h)=M(1,1;h)^{t^gamma} so we can look at
E[ exp(G(t)) ] ~ E[ exp(const t^{1-2H} X_t) ] = E[ exp( const*t^{(1-gamma)} X_t )]
for the Esscher transform of the process G_t instead of that of X_t (whose pdf is the solution of the fractional diffusion equation D^gamma + L_x = 0) .  Then we look at the Esscher transform with the constant h for X_t to look for a cancellation of t^gamma and get a martingale measure for G(t).  There is a martingale measure for G(t) anyway because it’s a diffusion.  So this could be the solution for an equivalent martingale measure.  Obviously with the explicit arbitrage examples for fBM one has to be careful but this approximation by diffusion is apparently quite good.
Attachments area

Read Full Post »

Older Posts »