# Flat-top Gaussian distributions

I want to simulate microscope images (2D gray-scale pixel arrays) of fluorescent beads, which are tiny balls of polymer doped with fluorescent dye. I assume that an ideal image (neglecting out-of-focus contributions/depth information) would closely resemble a rectangle function - so the 2D intensity profile would be a rectangle, the 3D profile a cylindrical flat-top distribution. But due to the resolution-limited optics, the true image will be blurred.

For most practical cases, this blurring can be approximated by a Gaussian blur, i.e. by convolution with a Gaussian kernel that has a width equivalent to the Airy disk. Since the rectangle function is discontinuous, I was looking for a smooth alternative which approximates the blurred rectangle function and found the super-Gaussian or higher-order Gaussian:

$$\displaystyle f{{\left({x}\right)}}={{f}_{{0}}{e}^{{-{\left(\frac{x}{{x}_{{0}}}\right)}^{{{2}{n}}}}}}$$

However, there is one feature that is missing: Since I want to simulate fluorescent beads of different sizes, the model function should be scalable in width while keeping the slopes constant. The super-Gaussian will spread out with increasing width, which would corresponds to an unphysical increase in blur with larger bead sizes.

The question therefore is: How to modify the super-Gaussian so the slopes are constant for a wide range of width $$\displaystyle{x}_{{0}}$$? If possible, the modification should be as simple as possible in order to facilitate further image processing computations (e.g. further convolution operations; my laptop is kinda slow...).

It is important to understand what each of the free parameters does to $$f$$. Specifically, $$f_0$$ scales the height of $$f$$; the maximum value attained corresponds to $$(x,y) = (0, f_0)$$. The parameter $$x_0$$ is a scaling factor in the $$x$$-direction. And for $$n \ge 1$$, the larger the value, the sharper the transition from $$f_0$$ to $$0$$ as $$x$$ increases.
What we would like to do is compute the slope of $$f$$ at its inflection point as a function of these parameters; that is to say, $$f'(x_c)$$ where $$x_c > 0$$ satisfies $$f''(x_c) = 0$$. This corresponds to a extremum for $$f'$$; i.e., where the slope is steepest. Logarithmic differentiation yields
$$\frac{d}{dx} \left[\log f(x)\right] = \frac{f'(x)}{f(x)} = -\frac{2n}{x_0} \left(\frac{x}{x_0}\right)^{2n-1} = g(x),$$ hence $$f''(x) = f'(x) g(x) + f(x) g'(x) = f(x) (g^2(x) + g'(x)).$$ Since $$f > 0$$ for all $$x$$, we need only consider the nontrivial critical points satisfying $$0 = g^2 + g'$$, which leads to the equation $$0 = 1 + 2n\left(\left(\frac{x}{x_0}\right)^{2n} - 1\right),$$ or $$x_c = x_0 \left(1 - \frac{1}{2n}\right)^{1/(2n)}.$$ Consequently, $$f'(x_c) = f(x_c)g(x_c) = -\frac{2f_0}{x_0} n e^{-1 + 1/(2n)} \left(1 - \frac{1}{2n}\right)^{1 - 1/(2n)} = -\frac{f_0}{f_c} (2n-1) e^{-1 + 1/(2n)}$$ If we regard $$f_0$$ as fixed, this establishes a relationship between $$x_0$$ and $$n$$ for which we have a desired slope at the nontrivial point of inflection of the curve.
For instance, if we want the peak to be $$f_0 = 1$$, and we originally have $$n = 3$$ and $$x_0 = 1$$, but we want to widen this curve so that we have the same slope when $$x_0 = 2$$, then we can numerically solve for $$n$$ that does this, yielding $$n \approx 6.06782$$. In general, the choice $$n_{\text{new}} \approx x_0 n$$ seems to be a good approximation for $$x_0 > 1$$.