Fourier Inversion for Affine Intensity Probability Densities
Summary
The document addresses recovering a probability density from the characteristic function of an affine stochastic intensity process. A question presents the Fourier inversion integral and a MATLAB attempt using CIR coefficients, but the characteristic function in that attempt omits the imaginary-unit argument in its exponential, so it does not represent the stated transform.
The answer provides a CIR example with the correct complex-valued characteristic function and evaluates the inversion numerically over a frequency domain. It compares the resulting density with the CIR noncentral chi-squared closed form and plots the transform and inversion integrand as diagnostics. The CIR case is illustrative because it has an analytic density; more general affine models require solving the associated Riccati equations, which may not have closed-form solutions. Numerical inversion also depends on integration and tolerance choices.
Key ideas
- Fourier inversion recovers a density by integrating the real part of the characteristic function times the complex exponential kernel.
- The characteristic function must use the imaginary argument, with its affine components evaluated consistently for complex inputs.
- For the CIR process, the inversion result can be checked against its noncentral chi-squared density.
- Plots of the characteristic function and inversion integrand help diagnose numerical integration behavior.
- General affine models may require solving Riccati equations without a closed-form solution.
Tags
Full text
# PDF Calculation by Fourier Inversion of Characteristic Function for Affine Intensity Process in Matlab
# PDF Calculation by Fourier Inversion of Characteristic Function for Affine Intensity Process in Matlab
I'm trying to use the Fourier inversion formula to plot the PDF of an Affine Stochastic Intensity Reduced Form Credit Model, given its characteristic function.
The characteristic function of an affine process $\lambda(t)$ is commonly given as
$$\phi_{\lambda(t)}(u) = \mathrm{E}[e^{iu\lambda(t)}] = \exp(A(t-s,iu)+B(t-s,iu)\lambda(s))$$
The Fourier inversion formula for PDF is
$$f_{\lambda(t)}(x)=\frac{1}{\pi}\int_0^\infty \mathrm{\Re}[e^{-iux}\phi_{\lambda(t)}(u)]du$$
Taking a CIR process (I’m aware that CIR has a $\chi^2$ Closed-Form PDF and the use of CIR here is just for illustration) which has coefficients:
$$A(T)=\frac{2\kappa\theta}{\sigma^2}\log\left(\frac{2\gamma e^{\frac{1}{2}(\kappa+\gamma)T} }{(\kappa+\gamma)(e^{\gamma T}-1)+2\gamma}\right)$$
$$B(T)=\frac{2 (e^{\gamma T}-1) }{(\kappa+\gamma)(e^{\gamma T}-1)+2\gamma}$$
In matlab script then, using quadrature for the integral, I (try to) calculate the PDF at the $\lambda$-points `X = (0:0.005:0.1)` for `T=1` with the code below.
Clearly there is a problem though (quite probably with `fcnPhi` below ) - Would greatly appreciate any help here
```
kappa = .07;
theta = .2;
sigma = .06;
lambda0 = .06;
T = 1;
gamma = 1;
A = ((2*kappa*theta)/(sigma^2))* log(2*gamma*exp(0.5*(kappa+gamma)*(T))./((kappa+gamma)*(exp(gamma*(T))-1)+2*gamma));
B = 2*(exp(gamma*(T))-1)/((kappa+gamma)*(exp(gamma*(T))-1)+2*gamma);
fcnPhi = @(u)( exp(u.*(A + B*lambda0)) );
X = (0:0.005:0.1)';
for i = 1:size(X,1)
x = X(i);
fcnPdfIntgrl = @(u)( real( exp(-1i.*u.*x) .* fcnPhi(u) ) );
pdf_X(i,1) = (1/pi) * integral(fcnPdfIntgrl,0,10000);
end
plot(X,pdf_X);
```
## Answer by StudentT (score 0, accepted)
https://quant.stackexchange.com/a/12706
Need to solve Riccati Equations with Complex Boundary Conditions for Char Function, no general closed form solution (apart from the "Basic" Affine model, CIR etc) a la Duffie http://www.mit.edu/~junpan/dps.pdf
Solution for CIR below
```
kappa = 2;
theta = .05;
sigma = .02;
lambda0 = .03;
T = 1;
X = (0.03:0.001:0.07)';
c = 2*kappa/(sigma^2*(1 - exp(-kappa*T))); % Scaling Factor
q = 2*theta*kappa/sigma^2 - 1; % Deg-of-Freedom
u = c*exp(-kappa*T)*lambda0;
v = c*X;
pdf_1 = 2*c*ncx2pdf(2*v,2*q+2,2*u);
fcnA = @(u)( -(2*kappa*theta/(sigma^2)) * log( 1 - ((sigma^2)/(2*kappa)) .* 1i.*u.*(1-exp(-kappa*T)) ) );
fcnB = @(u)( (1i.*u.*exp(-kappa*T)) ./ (1 - ((sigma^2)/(2*kappa)).*1i.*u.*(1-exp(-kappa*T)) ) );
fcnPhi = @(u)( exp( fcnA(u) + fcnB(u)*lambda0 ) );
pdf_2 = NaN(size(X));
for i = 1:size(X,1)
x = X(i);
fcnPdfIntgrl = @(u)( real( exp(-1i.*u.*x) .* fcnPhi(u) ) );
pdf_2(i,1) = (1/pi) * integral(fcnPdfIntgrl,0,Inf,'RelTol',1e-10,'AbsTol',1e-10);
end
subplot(6,1,1:2);
plot(X,pdf_1);
title('Probability Density Function by \chi^2');
subplot(6,1,3:4);
plot(X,pdf_2);
title('Probability Density Function by Fourier Inversion of CF');
U = (0:10:4000);
subplot(6,1,5);
plot(U,real(fcnPhi(U)));
title('Characteristic Function');
subplot(6,1,6);
plot(U,fcnPdfIntgrl(U));
title('Fourier Inversion Integrand');
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.