SERVING THE QUANTITATIVE FINANCE COMMUNITY

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Daniel, my mathematica code can easily be translated into pseudo code and programmed in any other language. Mathematic program has a very clear logical structure. The only restriction of the current program I see is that it takes just one term in the drift part of the SDE and mostly we need multiple terms in the drift when we want to have mean reversion and other interesting dynamics. But I will posting a specific pseudo code sometimes next week. I hope to be posting both a C++ and matlab program. I am sure an optimized C++ program will solve the SDEs with an order of expansion to 36 hermite polynomials in a few milliseconds and I am sure it will be possible to solve many SDEs and their stochastic integrals out to five years in small fraction of a second.
OK, the most original reference for this work is work by Platen and Wagner called Wagner-Platen formula. You have to google for Wagner-Platen formula.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Cuchulainn wrote:

OK, a source for SDEs has been found; have you a similar source for ODEs?

I believe that ODEs is still my original work. There were earlier expansions of ODEs that used two dimensional Taylor for solution of ODEs. But I did not follow the two dimensional Taylor formula and kept time functions in every term and integrated them to get a one dimensional expansion with integrations. IF there is no explicit functions of time in the right side of the ODE, Taylor expansion would give the same result but in case of time functions in right hand side of the ODEs, the use of two dimensional Taylor will be too cumbersome. I believe my approach to ODEs has never been used earlier.

amike
Posts: 76
Joined: October 21st, 2005, 12:57 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

99.9%

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

I will come back in a few days and describe my contribution to solution of SDEs after doing a thorough research about previous literature. I have several things in mind but I have to make sure. I am busy with a project and do not have extensive amount of time at the moment. But I will surely keep on posting interesting code and possibly some graphs.

Cuchulainn
Posts: 56674
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Breakthrough in the theory of stochastic differential equations and their simulation

I cannot imagine that iterated integrals are new; see the works by Volterra, Picard and other mathematicians of that era.
http://www.maths.manchester.ac.uk/~wpar ... Series.pdf

An ODE is equivalent to a Volterra integral equation of the 2nd kind.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Iterated integrals can be used in so many different ways and that does not mean that everywhere iterated integrals are used, it is the same setting in which I used them for ODEs. The PDF you have posted has little relevance to my work on ODEs. Can you please suggest something where iterated integrals have been used explicitly for ODEs in a similar manner to how I used them?
I developed the idea explicitly in the case of 1st order, 2nd order and nth order ODEs case and also presented programs to solve systems of  ODEs of nth order.

Cuchulainn
Posts: 56674
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Amin wrote:
Iterated integrals can be used in so many different ways and that does not mean that everywhere iterated integrals are used, it is the same setting in which I used them for ODEs. The PDF you have posted has little relevance to my work on ODEs. Can you please suggest something where iterated integrals have been used explicitly for ODEs in a similar manner to how I used them?
I developed the idea explicitly in the case of 1st order, 2nd order and nth order ODEs case and also presented programs to solve systems of  ODEs of nth order.

OK. The integral and ODE approach are mirror images of each other.
It is really up to you to show it is original work. A good idea is to locate ODE academics and ask them.
Iterated integrals is not my cup of tea, since I prefer numerics. Each to his own, I suppose.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Cuchulainn wrote:
Amin wrote:
Iterated integrals can be used in so many different ways and that does not mean that everywhere iterated integrals are used, it is the same setting in which I used them for ODEs. The PDF you have posted has little relevance to my work on ODEs. Can you please suggest something where iterated integrals have been used explicitly for ODEs in a similar manner to how I used them?
I developed the idea explicitly in the case of 1st order, 2nd order and nth order ODEs case and also presented programs to solve systems of  ODEs of nth order.

OK. The integral and ODE approach are mirror images of each other.
It is really up to you to show it is original work. A good idea is to locate ODE academics and ask them.
Iterated integrals is not my cup of tea, since I prefer numerics. Each to his own, I suppose.

Yes, I think it would be more interesting to give an idea about how previous researchers and scholars have used iterated integrals in different settings. And then put my work in a right context. Even for SDEs where credit for original work goes to Platen and his collaborators, I see my contribution in the sense that I developed the idea to practically use higher order expansions. Earlier, I have not seen anything in literature that goes beyond fourth order. In fact if you use monte carlo, though not always but sometimes you cannot take a very high expansion order since outliers and distributional errors can play havoc with the density when  high order expansions are used with monte carlo so I suggested a density formulation which is more suitable when we have to take order of expansion to high orders and we want to take terminal time to several years. Again I do not believe that people had previously used related expansions to a time frame of several years with accuracy but now you can easily expand some SDEs out to five years very easily. I also practically developed the idea of higher order iterated dz-integrals and dt-integrals where dynamics of variables in integrand are given by an SDE. Though possible in light of previous research but explicitly developing the idea has merits. So I have decent enough contribution among the original work of other scholars. I would be writing a post here after a week or so in which I would place everything in the right context starting from the original work of Wagner-Platen formula and also include all the related work of other researchers.
If you are happy with numerics, the last mathematica program I posted is mostly numerics and would be of interest to you.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Amin wrote:
Here is a program that will calculate the density of an SDE using hermite polynomials. In the following program, I have used 24 hermite polynomials for expansion of driftless CEV SDE density at two years. I have kept the drift at zero and this is just an initial experimentation. I have not carefully checked everything and posting the program in the hope that it would be helpful for others. I will stay away from this project for a few days and possibly come back next week and make more changes. Here is the code.
In[83]:= Clear[x,t,x0,Y,P1,P2,l1,l2,Z,mu,sigma,mu0,sigma0,alpha, beta, gamma,a0,k,k1,m,L1,L2,YAns,H,Hz,X1,fX1,DfX1,Nn,n,HCoeff,ZCoeff,DZCoeff,zz];
In[84]:= P1=24;
In[85]:= P2=24;
In[86]:= L1=0;
In[87]:= L2=0;
In[88]:= Array[Y,{P1+L1+1,P1+L1+1,P2+L2+1},{0,0,0}];
In[89]:= For[k=0,k<=P1+L1,k++,(For[m=0,m<=P1+L1,m++,(For[n=0,n<=P2+L2,n++,(Y[k,m,n]=0);]);]);];
In[90]:= a0=1;
In[91]:= mu0=0;
In[92]:= sigma0=.75;
In[93]:= alpha=1;
In[94]:= gamma=.85;
In[95]:= beta=0;
In[96]:= Y[L1,L1,L2]=a0;
In[97]:= For[k=0,k<P1,k++,(For[m=0,m<=If[k<=P2,k,P2],m++,(l0=L1+k-m;l3=L2+m;
For[n=0,n<=l0-L1,n++,(l1=l0-n;l2=L1+n;Y[l1+1,l2,l3]=Y[l1+1,l2,l3]+SetPrecision[Y[l1,l2,l3]*(alpha+(l1-L1)*beta+(l2-L1)*2*gamma+(l3-L2)*gamma-(l1-L1)-2*(l2-L1)-(l3-L2))*mu0,50];
Y[l1,l2+1,l3]=Y[l1,l2+1,l3]+SetPrecision[Y[l1,l2,l3]*.5*(alpha+(l1-L1)*beta+(l2-L1)*2*gamma+(l3-L2)*gamma-(l1-L1)-2*(l2-L1)-(l3-L2))*(alpha+(l1-L1)*beta+(l2-L1)*2*gamma+(l3-L2)*gamma-(l1-L1)-2*(l2-L1)-(l3-L2)-1)*sigma0^2,50];
If[l3<L2+P2,(Y[l1,l2,l3+1]=Y[l1,l2,l3+1]+SetPrecision[Y[l1,l2,l3]*(alpha+(l1-L1)*beta+(l2-L1)*2*gamma+(l3-L2)*gamma-(l1-L1)-2*(l2-L1)-(l3-L2))*sigma0,50]),0];);];)];);];
In[98]:= Array[HCoeff,P2+L2+1,0];
In[99]:= For[k=0,k<P2+L2+1,k++,HCoeff[k]=0;]
In[100]:= x=1;
In[101]:= t=2;
In[102]:= For[k=0,k<=P1,k++,(For[m=0,m<=If[k<=P2,k,P2],m++,(l0=L1+k-m;l3=L2+m;
For[n=0,n<=l0-L1,n++,(l1=l0-n;l2=L1+n;
HCoeff[l3]=HCoeff[l3]+SetPrecision[Y[l1,l2,l3]*x^(alpha+(l1-L1)*beta+(l2-L1)*2*gamma+(l3-L2)*gamma-(l1-L1)-2*(l2-L1)-(l3-L2))*(Sqrt[t^(2*l1+2*l2-2*L1+l3)]*Sqrt[(2*l1+2*l2-2*L1)!])/(Sqrt[(2*l1+2*l2-2*L1+l3)!] *((l1+l2-L1)!))/Sqrt[l3!],50];)];)];);];
In[103]:= Array[Hz,{P2+L2+1,P2+L2+1},{0,0}];
In[104]:= For[k=0,k<P2+L2+1,k++,For[m=0,m<P2+L2+1,m++,Hz[k,m]=0;]];
In[105]:= Hz[0,0]=1.0;
In[106]:= For[k=0,k<P2+L2,k++,(For[m=0,m<=k,m++,(Hz[k+1,m+1]=SetPrecision[Hz[k,m],50];
If[m>=1,Hz[k+1,m-1]=SetPrecision[Hz[k+1,m-1]-m*Hz[k,m],50],0];)])];
In[107]:= Array[ZCoeff,P2+L2+1,0];
In[108]:= For[k=0,k<P2+L2+1,k++,ZCoeff[k]=0];
In[109]:= For[k=0,k<P2+L2+1,k++,(For[m=0,m<=k,m++,ZCoeff[m]=ZCoeff[m]+SetPrecision[Hz[k,m]*HCoeff[k],50]])];
In[110]:= Array[DZCoeff,P2+L2,0];
In[111]:= For[k=0,k<P2+L2,k++,DZCoeff[k]=0];
In[112]:= For[k=0,k<P2+L2,k++,DZCoeff[k]=SetPrecision[ZCoeff[k+1]*(k+1),50]];
In[113]:= Nn=81;
In[114]:= Array[X1,Nn,0];
In[115]:= Array[DfX1,Nn,0];
Array[fX1,Nn,0];
Array[zz,Nn,0];
In[118]:= For[n=0,n<Nn,n++,(X1[n]=0;DfX1[n]=0;fX1[n]=0;zz[n]=0;)];
In[119]:= For[n=0,n<Nn,n++,(zz[n]=n*.1-4;X1[n]=0;DfX1[n]=0;fX1[n]=0;
X1[n]=ZCoeff[0];DfX1[n]=DZCoeff[0];For[k=1,k<P2+L2+1,k++,(X1[n]=X1[n]+SetPrecision[ZCoeff[k]*zz[n]^k,50];If[k<P2+L2,DfX1[n]=DfX1[n]+SetPrecision[DZCoeff[k]*zz[n]^k,50],0];)];
fX1[n]=SetPrecision[PDF[NormalDistribution[0,1],zz[n]]/Abs[DfX1[n]],50];
)];
In[120]:= data1=Table[{X1[n],fX1[n]},{n,0,80}];
In[122]:= ListLinePlot[data1]

For those friends who downloaded the above program in post 673, I want to mention that sometimes we might like to take the same order of volatility in volatility noise terms and quadratic variation terms. Quadratic variation terms have order of sigma^2. I want to post a next version of the program after about a week in which I will make it possible for users to take different order in each of drift, quadratic variations and volatility terms. I believe when volatility term has a power closer to .5 i.e. heston-like, in that case it might make the model stable if we take order in quadratic variations expansion half of the order in volatility noise expansion terms and then we will have similar order in powers of sigma, possibly making the expansion stable. Again for example if we take the expansion order of quadratic variations to two, in that case they will have an order in terms of sigma of sigma^4 and we would like to take the order in expansion of volatility noise terms to 4, making their order in terms of sigma also to sigma^4. So if quadratic variations are expanded to half the order of volatility noise terms, the model might become stable for quite high hermite polynomials. In the next version of the program, we will easily be able to experiment with this.
When I wrote this above program or its earlier versions, I was thinking that expansion order in dt-integrals of drift and quadratic variations will always be higher or equal to the expansion order of volatility noise terms or hermite polynomials.

Cuchulainn
Posts: 56674
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Breakthrough in the theory of stochastic differential equations and their simulation

If you are happy with numerics, the last mathematica program I posted is mostly numerics and would be of interest to you.

I am happy when the qualitative behaviour (existence results etc.)  of ODE/SDE have been finalised  and then move to numerics. So, both are needed.

Cuchulainn
Posts: 56674
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Breakthrough in the theory of stochastic differential equations and their simulation

If you are happy with numerics, the last mathematica program I posted is mostly numerics and would be of interest to you.

I am happy when the qualitative behaviour (existence results etc.)  of ODE/SDE have been finalised  and then move to numerics. So, both are needed. You can't have one without the other.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Towards the end of this week, I hope to post very interesting stuff including graphs making comparison of distributions produced by the method with true distributions out to five years and ten years. I want to make comparisons of many different distributions of the kind that are used in stochastic volatility models and distributions of their variance integrals. I am sure, it will get very interesting. And I am looking forward to it.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

I am working on a better algorithm and related mathematica program for Ito-Taylor expansion of SDEs that would be based on only first 4-6 hermite polynomials and it will evaluate the coefficients of hermite polynomials every .25 or .5 years. There will be one calculation of hermite polynomials at the start but we will have to calculate the coefficients after .25/.5 years for every node on the tree that branches just once at origin. So if there are forty branches of the tree, we will have to do forty calculations of hermite polynomial coefficients every .25/.5 year. I have ideas about an efficient program and hope to post it here in a few days. We would keep the discretization time interval to a value where most nice SDEs would converge using only a handful of first few hermite polynomials keeping the whole process efficient enough. I hope to post the new algorithm in a few days.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

Amin wrote:
I will take a few more days to complete the paper but here are a few formulas for friends. Here I give the general algorithm for the type of integrals where only dz and dt integrals follow each other in any order. Like many other possibilities, one four order repeated integral with two dz uncertainties could be$\int _0^t \text{\sigma dz}(s)\int _0^s\text{du}\int _0^u\text{dv}\int _0^v\sigma \text{dz}(w)$The value of the above kind of integrals, as long as there is no explicit t, does not depend upon the sequence order(whether dz integral comes first or dt integral comes first does not change the value of the total integrals) so variance can be easily calculated by Ito Isometry. The order of hermite polynomial depends upon the number of normal uncertainties so is equal to number of dz integrals. Here is the simple formula to calculate the hermite polynomial representation of the integrals which equals$H_n(N)*\frac{\sqrt{\text{Variance}}}{\sqrt{n!}}$here n, which is the order of hermite polynomials, equals the number of normal uncertainties.   I will give a few examples$\int _0^t \text{\sigma dz}(s)\int _0^s\text{du}=H_1(N)\frac{\text{\sigma t}^{1.5}}{\sqrt{1!}\sqrt{3}}$$\int _0^t \text{\sigma dz}(s)\int _0^s\text{\sigma dz}(u)=H_2(N)\frac{\sigma ^2t}{\sqrt{2!}\sqrt{2}}$$\int _0^t \text{\sigma dz}(s)\int _0^s\text{du}\int _0^u\text{\sigma dz}(v)=\int _0^t \text{\sigma dz}(s)\int _0^s\text{\sigma dz}(u)\int _0^u\text{dv}=\int _0^t \text{ds}\int _0^s\text{\sigma dz}(u)\int _0^u\text{\sigma dz}(v)=H_2(N)\frac{\sigma ^2t^2}{\sqrt{2!}\sqrt{12}}$$\int _0^t \text{\sigma dz}(s)\int _0^s\text{du}\int _0^u\text{dv}=\int _0^t \text{ds}\int _0^s\text{\sigma dz}(u)\int _0^u\text{dv}=\int _0^t \text{ds}\int _0^s\text{du}\int _0^u\text{\sigma dz}(v)=H_1(N)\frac{\sigma ^2t^{2.5}}{\sqrt{1!}\sqrt{20}}$$\int _0^t \text{\sigma dz}(s)\int _0^s\text{\sigma dz}(u)\int _0^u\text{\sigma dz}(v)=H_3(N)\frac{\sigma ^3t^{1.5}}{\sqrt{3!}\sqrt{6}}$Fourth order and higher integrals can be evaluated to perfect precision using this method so I am not giving examples for that.

Ok friends, I believe that this is an error and all integrals do not commute. I will soon be posting a new program to calculate these integrals in a nice algorithmic fashion. But just want to warn friends that this is a mistake and will put the results slightly off.
Calculation of coefficients of stochastic integrals in an algorithmic fashion is perfectly fine but variance and calculations of related stochastic integrals is slightly off in many cases.

Amin
Topic Author
Posts: 2032
Joined: July 14th, 2002, 3:00 am

Re: Breakthrough in the theory of stochastic differential equations and their simulation

I was able to find these very nice recursions for integrals of products of time powers and hermite polynomials of various orders. Using this I get very perfect match when I expand using Ito-Taylor the powers of lognormal and time integrals of squared lognormal etc. I will soon be posting new matlab and mathematica programs with the corrections made for integrals. And calculations are no more complex than what we did before. But for friends who would be interested, these are the recursions for various stochastic integrals of hermite polynomials and their time products. With these recursions, we can very easily calculate all the stochastic integrals that arise in Ito-Taylor expansions whatever the order of integrals.

\int_0^t s^m H_n (z(s)) ds = t^(m+1) H_n (z(t))/( m+1) (1-sqrt(n)/sqrt(2m+n+2))

\int _0^t s^m H_n(z(s)) dz(s)=t^m H_(n+1)(z(t))/sqrt(n+1)/sqrt(2m+n+1)

Here H_n(z(t)) is hermite polynomial of degree n and H_(n+1)(z(t)) is hermite polynomial of degree n+1.