r - Use FFT fft() to compute a Riemann sum -


i calculate following sum applying fast fourier transforms (fft). want compute following riemann sum approximation using fft :

enter image description here here psy function i'm using :

psyfun<-function(u,t,r,q,sigma,lmbda,meanv,v0,rho){   j  <- as.complex(1i)   <- lmbda*meanv   b <- lmbda   d <- sqrt((j*rho*sigma*u-b)**2+(u**2+j*u)*sigma**2)   g <- (b-j*rho*sigma*u-d)/(b-j*rho*sigma*u+d)   ret <- exp(j*u*(r-q)*t)   ret <- ret*exp((a/sigma**2)*((b - rho*j*sigma*u - d)*t - 2.0*log((1-g*exp(-d*t))/(1-g))))   return (ret*exp((v0/sigma**2)*(b - rho*j*sigma*u - d)*(1-exp(-d*t))/(1-g*exp(-d*t)))) } 

here sample parameters :

r = 0.025 ,q= 0.01, sigma = 0.2, lmbda = 0.5, meanv = 0.5, v0 = 0.5 , rho = 0.3 

i want compute values k , t equals :

k1=172.77 , t1 = 0.197, k2= 75.63 , t2 = 0.563, k3 = 269.54 , t3 = 0.2648

i implement following code it:

  n=2^10           # number of subdivision in [0,a]   alpha=2          # alpha    delta= 0.25      # delta= a/n  value of w (w in [0,a])   lambda=(2*pi)/(n*delta)   j=seq(1,n,1)   k=seq(1,n,1)   b=(lambda*n)/2   strike= -b+(k-1)*lambda   strike= exp(strike)   res=c()   (i in 1:n){     w=delta*(i-1)      #  w= j*delta 1 n w=(i-1)*delta     w_fc=w-(alpha+1)*1i     phi= psyfun(w_fc,t,r,q,sigma,lmbda,meanv,v0,rho)     phi=phi*exp(-r1*(t))     phi=phi/(alpha^2+alpha-w^2+1i*(2*alpha+1)*w)     phi=phi*delta*exp(1i*w*b)     res=rbind(res,phi)   }     result=re(fft(res))*exp(-alpha*(-b+(k-1)*lambda))/pi 

i obtain k numbers of values how 1 correspond k1,k2,k3. can recommend procedure implement computation? thanks

i have no previous experience in fast fourier transforms (fft) processing, appreciate tips , pointers related mathematics / methods / code in addition advice on how better approach programmatically.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -