# Is there a way to approximate a function as sum of Gaussian?

I'm a chemist, and my friend give me a spectroscopic data that was supposed to be sum of several Gaussian function $$(G(x)=Ae^{-B(x-C)^2})$$.

Let's say the data is given as function $$f(x)$$, is there a way to write

$$f(x)=\sum_{n}{}A_ne^{-B_n(x-C_n)^2}$$

Just what we can do in Fourier series?

• If you hear about "radial basis functions", this is most likely one variant. This type of kernel is widely used to find empirical forms of a sampled function, something like a continuous histogram, and is also the second example for alternative kernels in support-vector machines (SVM). This is largely non-linear regression, so not a nice transform like the FFT. Jun 7, 2023 at 6:57

## 1 Answer

To elaborate Lutz Lehmann's comment, you can do kernel regression using the Gaussian kernel function.

General Flow

We use matrix notation $$\mathbf{f}=\mathbf{K}\mathbf{A}$$ for conciseness:

$$\begin{Bmatrix} f\left(x_{1}\right) \\ f\left(x_{2}\right) \\ \vdots \\ f\left(x_{n}\right) \end{Bmatrix} = \begin{bmatrix} e^{-B_{1}\left(x_{1}-C_{1}\right)^{2}} & e^{-B_{2}\left(x_{1}-C_{2}\right)^{2}} & \cdots & e^{-B_{n}\left(x_{1}-C_{n}\right)^{2}} \\ e^{-B_{1}\left(x_{2}-C_{1}\right)^{2}} & e^{-B_{2}\left(x_{2}-C_{2}\right)^{2}} & \cdots & e^{-B_{n}\left(x_{2}-C_{n}\right)^{2}} \\ \vdots & \vdots & \ddots & \vdots \\ e^{-B_{1}\left(x_{n}-C_{1}\right)^{2}} & e^{-B_{2}\left(x_{n}-C_{2}\right)^{2}} & \cdots & e^{-B_{n}\left(x_{n}-C_{n}\right)^{2}} \\ \end{bmatrix} \begin{Bmatrix} A_{1} \\ A_{2} \\ \vdots \\ A_{n} \end{Bmatrix}$$

The coefficients $$A_{i}$$s are obtained by solving the system of linear equations, typically using pseudo - inverse.

Caveat

While $$A_{i}$$s are obtained from solving the system of equations, you are the one who needs to choose (or tune) the coefficients $$B_{i}$$s and $$C_{i}$$s yourself. Some really rough guides:

• The smaller $$B_{i}$$s are, the smoother your approximation will be.
• Typically people use $$C_{i}=x_{i}$$ so the matrix $$\mathbf{K}$$ will have larger values on its diagonal which will stabilize the matrix solver