Approximate a product of a polynomial and a Gaussian with two Gaussians

160 Views Asked by At

I have the following polynomial ($x$) multiplied by a Gaussian,

$$ f_b(x) = N_b x \exp(-b x^2) $$

that I want to approximate with two (a positive and a negative) Gaussians:

$$ f_a(x) = N_a [ \exp(-a (x-h)^2) - \exp(-a (x+h)^2)] $$

where $a,b,N_a,N_b,h \in \mathbb{R}^+$. To better understand it, I plotted the problem with $N_a=N_b=a=b=h=1$,

enter image description here

where the blue curve is $f_b(x)$ and the orange curve is $f_a(x)$ which is composed of the yellow and green one, the two Gaussians inside $f_a(x)$.

So I want to minimize the following $L_2$ norm (if that's correct?) between the two functions:

$$ \min_{N_a,a,h} \int_\mathbb{R} \mathrm{d} x \vert f_b(x) - f_a(x) \vert ^2 $$

and find the best parameters $N_a,a,h$ for which the overlap will be closest to 0. I feel this should even be possible analytically. The resulting $N_a,a,h$ are dependent on $N_b$ and $b$, hence maybe rather $N_a(N_b,b)$, $a(N_b,b)$, and $h(N_b,b)$.

Thanks for the help.

2

There are 2 best solutions below

2
On BEST ANSWER

Let's rescale $f$ and $x$ such that $N_b = 1$ and $b = 1/2$ to get rid of some constants. Unfortunately, though, it doesn't make minimizing that integral any easier. So let's try matching features instead. The obvious things to match are the derivative at the origin and the location of the maximum. Let's try that analytically.

  1. Derivative at the origin: $f_b'(0) = 1$, so a quick calculation gives $$ 4aN_a h e^{-ah^2} = 1 $$ This can be solved for $N_a$ relatively easily, giving $$ N_a = \frac{e^{ah^2}}{4ah} $$
  2. X-coordinate of maximum: $f_b$ has a maximum at $x = 1$, so we get $$ (1+h)e^{-a(1+h)^2} = (1 -h)e^{-a(1-h)^2} $$ This is actually solvable for $a$, giving $$ a = \frac{1}{4h}\ln\left(\frac{1+h}{1-h}\right) \\ N_a = \frac{\left(\frac{1+h}{1-h}\right)^{h/4}}{\ln\left(\frac{1+h}{1-h}\right)} $$

Now at this point we would use this to solve for the value at the maximum and set that equal to $e^{-1/2}$. Only one problem: it's never equal to this value. Instead, that's the limit as $h\rightarrow 0$. So what's going on here? For $0 < h < 1$, the smaller $h$ is, the better approximation you get. Which isn't exactly surprising, as $f_b$ is essentially the derivative of $f_a$. But presumably you don't want to use a very small $h$. So, pick an $h$ you find suitably large, calculate $N_a$ and $a$ from the above, and use that. Keep in mind that the larger $h$ is, the worse the approximation becomes for large $x$.

Here's a sample plot for $h = 1/2$. Approximation is pretty good for low $|x|$.

0
On

Starting from @eyeballfrog's answer, using also $N_b=1$, $b=\frac 12$ and $N_a = \frac{e^{ah^2}}{4ah}$

$$\Phi(a,h)= \int_0^\infty \Big[f_b(x) - f_a(x)\Big]^2\,dx=\frac{\sqrt{\pi }}{32}\Bigg[8+ \sqrt{2} \left(\frac{e^{2 a h^2}-1}{a^{5/2} h^2}-\frac{32 e^{\frac{2 a^2 h^2}{2a+1}}}{(2 a+1)^{3/2}}\right)\Bigg]$$

The numerical minimization of the norm (not easy) leads to $\color{red}{a\sim \frac {11}{20}}$ for which $\color{red}{h\sim \frac 12}$ corresponding to $\Phi= 3.54\times 10^{-6}$.

For $h$, this is the same conclusion as in @eyeballfrog's answer and that $\frac {11}{20}$ is the third rational approximation of $\frac{\log (3)}{2}$ (!!!).

Edit

If the problem is to make the best approximation over a given range $(0\leq x \leq t)$, we could do the same considering instead $$\Psi(a,h)= \int_0^t \Big[f_b(x) - f_a(x)\Big]^2\,dx$$ $$\Psi(a,h)\propto \frac 12 \left(\sqrt{\pi } \text{erf}(t)-2 e^{-t^2} t\right)+\frac{ e^{-\frac{1}{2} t (2 a (2 h+t)+t)} \left(e^{4 a h t}-1\right)}{a (2 a+1) h}+$$ $$\sqrt{2 \pi }\frac{ e^{\frac{2 a^2 h^2}{2 a+1}} \left(\text{erf}\left(\frac{2 a (h-t)-t}{\sqrt{4 a+2}}\right)-\text{erf}\left(\frac{2 a (h+t)+t}{\sqrt{4 a+2}}\right)\right)}{(2 a+1)^{3/2}}+$$ $$\frac{\sqrt{2 \pi }}{32}\frac{ e^{2 a h^2} \left(\text{erf}\left(\sqrt{2a} (h+t)\right)-\text{erf}\left( \sqrt{2a} (h-t)\right)\right)-2 \text{erf}\left(\sqrt{2a} t\right)}{a^{5/2} h^2}$$