Serving the Quantitative Finance Community

• 1
• 2

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Hunting the Dirac Delta

I am looking for a good approximation ... there are many out there but ideally it should be

1. Ideally, $C^\infty$ smooth (a tempered distribution).
2. Always positive
3. Preserves/compatible with monotone schemes
4, Works with the PDE for gamma sensitivity
5. A bunch of deltas out there that don't cut the mustard.
6, No handwaving and well-known fixes.

The derivative of Fermi Dirac function looks not bad but I can't see the full consequences. An approximation of an approximation makes things worse?
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Alan
Posts: 2767
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Hunting the Dirac Delta

Suppose a lattice $\{x_i\}$ with spacing $dx$. Assume a class of approximate Dirac Deltas functions with area=1 for all and centered at  $x_i = 0$. I think the critical property is that, evaluated at the centered lattice point, the function value tends to $1/dx$ as $dx \rightarrow 0$.
Once you've got that, I will guess just about anything will work.

I always use/suggest the non-smooth function $f(x) = \frac{1}{dx} 1_{\{|x| < 0.5 \, dx\}}$.
Sure, it violates 1. If it's really important to have Property 1, you could always just round the corners.

Alan
Posts: 2767
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Hunting the Dirac Delta

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

Suppose a lattice $\{x_i\}$ with spacing $dx$. Assume a class of approximate Dirac Deltas functions with area=1 for all and centered at  $x_i = 0$. I think the critical property is that, evaluated at the centered lattice point, the function value tends to $1/dx$ as $dx \rightarrow 0$.
Once you've got that, I will guess just about anything will work.

I always use/suggest the non-smooth function $f(x) = \frac{1}{dx} 1_{\{|x| < 0.5 \, dx\}}$.
Sure, it violates 1. If it's really important to have Property 1, you could always just round the corners.
Unfortunately, this option leads to quite a lot of numerical issues and the inevitable fixes in the literature, which is a bit depressing.
Taking the basic SDE dX = sig dW we get the 1-factor FPE diffusion PDE Q_t = 1/2 sig^2 Q_xx  with delta d(x) as initial condition. Even for this special case of d(x) = 1/h (h = dx):

1. Crank Nicolson will give oscillation or negative values unless dt == k < O(h^2). So, it behaves like explicit Euler.
2. Other "suspects" fdm also have issues.
3. A solution is to transform  to natural time of Brownian motion $\tau = \sqrt t$ which fixes this particular problem, giving positive density under all combinations.

At this stage, is there a way to replace d(x) in the initial condition and "hide" it somewhere else in the PDE? Having it elsewhere maybe less damaging that as a spike?
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

Yes, that's an idea, the bump functions, maybe. They are smooth but not $C^{\infty}$ .. don't know what the relation is with delta functions. They do look promising.
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

Yes, that's an idea, the bump functions, maybe. They are smooth but not $C^{\infty}$ .. don't know what the relation is with delta functions. They do look promising.
Aka mollifiers in Functional Analysis. They must have integral == 1, which is tricky, especially in  higher dimensions.
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Alan
Posts: 2767
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Hunting the Dirac Delta

There is an example of using my non-smooth suggestion with NDSolve (including code) in my Vol II book, pages 462-464. It works quite well, as Fig 10.5 there shows.

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

There is an example of using my non-smooth suggestion with NDSolve (including code) in my Vol II book, pages 462-464. It works quite well, as Fig 10.5 there shows.
This looks very good, Alan.
I reckom NDSolve (using Bulisch-Stoer) can handle many kinds of pesky deltas:

1.  avoiding oscillations and negative values
2. what is accuracy order (high?), order 4 in space, order 5 in time?
3. sanity check: integral == 1. (cdf)
4. what about small and large T?

Now, I have modelled the PDE for option gamma (differentiate  BSPDE twice wrt S) with a Gaussian as delta. I used C++, centred differencing in S and Bulisch-Stoer in time (Boost C++ odeint library). I get excellent results.

Will post details later today.

Meanwhile, back at the ranch, people are looking for fixes for traditional fdm. It is based on flawed assumptions and expectations. A kind of wasted effort.
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

Solving the PDE for gamma using Bulisch-Stoer and Cash Karp with Gaussian delta function
Attachments
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

We also stress tested for Speed = dgamma/dS . We used the Complex Step Method to compute the derivative of delta, which is Speed’s payoff.

// Distributions and delta functions
using cvalue_type = std::complex<value_type>;
cvalue_type deltaFunction(cvalue_type z, value_type a, value_type eps)
{
return std::exp(-(z - a)*(z - a) / (2.0*eps*eps))
/ std::sqrt(2.0*3.14159265359*eps*eps);
}

value_type deltaFunctionReal(value_type x, value_type a, value_type eps)
{
return std::exp(-(x - a)*(x - a) / (2.0*eps*eps))
/ std::sqrt(2.0*3.14159265359*eps*eps);
}

value_type derivativeDeltaFunction(value_type x, value_type a, value_type eps,
value_type h)
{
//     value_type h = 0.01;
cvalue_type z(x, h);
return std::imag(deltaFunction(z, a, eps))/h;
}

Attachments
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Alan
Posts: 2767
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Hunting the Dirac Delta

There is an example of using my non-smooth suggestion with NDSolve (including code) in my Vol II book, pages 462-464. It works quite well, as Fig 10.5 there shows.
This looks very good, Alan.
I reckom NDSolve (using Bulisch-Stoer) can handle many kinds of pesky deltas:

1.  avoiding oscillations and negative values
2. what is accuracy order (high?), order 4 in space, order 5 in time?
3. sanity check: integral == 1. (cdf)
4. what about small and large T?

Now, I have modelled the PDE for option gamma (differentiate  BSPDE twice wrt S) with a Gaussian as delta. I used C++, centred differencing in S and Bulisch-Stoer in time (Boost C++ odeint library). I get excellent results.

Will post details later today.

Meanwhile, back at the ranch, people are looking for fixes for traditional fdm. It is based on flawed assumptions and expectations. A kind of wasted effort.
NDSolve is order 4 in space and uses adaptive time-stepping. In my experience it handles both small and large T well. It's especially good for large T when the solution tends to a constant-in-time function (the soln to the associated elliptic problem), as it will take *very* large time steps when warranted.

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

The "box" delta you use is also very good. I used it with the Gamma PDE and it works fine.

I also did an initial heat kernel with ADE with OK results.  CN is all over the place.
Attachments
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

Can FPE be written in the self-adjoint form?

$\frac{\partial p}{\partial t} =$ (A(x) (B(x) p)_x)_x ?

and for n-factor.
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)

katastrofa
Posts: 7162
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Hunting the Dirac Delta

You need delta or actually its derivative?

Cuchulainn
Topic Author
Posts: 18786
Joined: July 16th, 2004, 7:38 am
Location: Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch

### Re: Hunting the Dirac Delta

You need delta or actually its derivative?
I have now no issues with delta nor its derivative. BTW p is transition probability, p(t = 0) = delta.

the Q can I write FPE in verry nice compact form and what are the advantages

p_t = (A (B p_x))_x

it's just another PDE.
Leftist, Alt Right, Marxist, Nihilist, Neo Celtic Reconstructionists, and splitters, all opinions appreciated. (Obviously that doesn't include Liberal Democrats.)