Equation of a flat top gaussian

2.6k Views Asked by At

I'm trying to map a set of data points that seems to form a kind of a flat top gaussian in one dimension. I'm used to fitting data to a gaussian using non-linear least squares. I'm trying to understand how to do the same, for a flat top gaussian?

1

There are 1 best solutions below

9
On BEST ANSWER

The approach is the same. A Gaussian distribution has two parameters, the mean and standard deviation. You add up the square of the error of each point to get an error function, which depends on those two parameters, then minimize the error function to find the best fit set of parameters. For your case, you need to define the "flat topped Gaussian" as a function of some number of parameters. You might just chop off the head of the Gaussian at $\pm n \sigma$, leading to something like $$M(\mu , \sigma , n,x)=\begin {cases} \frac K{\sqrt {2 \pi \sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma ^2}}&|x| \gt n \sigma \\ \frac K{\sqrt {2 \pi \sigma^2}} e^{-\frac{(n \sigma-\mu)^2}{2\sigma ^2}}&|x| \le n \sigma\end {cases}$$ where you choose $K$ as a function of $n$ so the integral over the distribution remains $1$ Now compute the error of each point from $M$, square it, add them all up, and that is your error function to minimize over the parameters.