November 20th, 2008, 10:46 pm
hi everybody, I am currently implementing on matlab 3 models of stochastic volatility, and I have trouble with CEV implementation. I don't know why but the summation of the product of the density gamma distribution with the complementary cumulative does not work. I tried to fix it but I don't know what is wrong. Here is the code of the matlab function I created, if anyone could help me out on this, it will be very appreciatedfunction callCEV= CEV(N,alpha,sigma,r,q,T,s,E)% E=strike/N=upperbound of the summation/q=dividend% proportional to S%%CEV model: ds = s*r*dt+ s^(alpha/2)*sigma * dwt%%Parameter used in the gamma functionsk = (2*(r-q))/(sigma^2*(2-alpha)*(exp((r-q)*(2-alpha)*T)-1));x = k * s^(2-alpha)*exp((r-q)*(2-alpha)*T);v = k * E^(2-alpha);Som1=0;Som2=0;m1=0;m2=0;for n=0:1:N m1=n+1+1/(2-alpha); m2=n+1; Som1 = Som1 + gampdf(x,m2,1) * (1-gamcdf(v,m1,1)); Som2 = Som2 + gampdf(x,m1,1) * (1-gamcdf(v,m2,1));endcallCEV= s*exp(-q*T)*Som1 - E*exp(-r*T)*Som2;