# Alternatives to constrained non-linear optimization: a case study with Gaussian curve fitting

I have a set of data points distributed like a bell-shape curve with varying amplitudes and widths. I need to parameterize these data points and a Gaussian with amplitude, width and offset parameters function is just perfectly suited.

My y-values are defined between at 8 different points between [-2.3561 3.1415] and I am interested fitting a Gaussian that is centered at 0.

out      = amp.*exp( - (0.5*(X./sd).^2 )) + offset;


Optimizing the likelihood function following an initial estimation of these 3 parameters works generally very good. And this has been already discussed elsewhere in this site.

The problem starts when my data points are described by a very shallow bell-shaped profile, looking like a second order polynomial with a small coefficient, so that the highest and lowest points do not have so much of a difference.

In these cases the optimization procedure returns extremely high sigma and amplitude values. It basically tries to fit the data with the tip of an amazingly wide Gaussian, which by far exceeds the range of my x-values. These huge fitted values destroy my statistics, because ultimately I would like to do some statistics with these numbers comparing different groups. In these situations, I would like to have a small amplitude and relatively wide width parameter returned from the optimization procedure and this would just do the job good enough.

I tried constrained optimization, trying to limit valid values for the parameters. But this also results in values that are densely accumulated on the boundary limits.

I was wondering what would be a general approach to tackle this kind of situations? If you have encountered similar situation I would be happy to hear about your experience...

Here are some examples of data: Gray Curve: Initial Estimates Red Curve: Fitted Gaussian Blue Curve: Data

data_01: This shows a situation where sigma and amp parameters are huge, even though a very small amplitude value would do the job good.

-2.3562 1.2210 -1.5708 -1.6224 -0.7854 -0.1330 0 -0.1126 0.7854 -0.0745 1.5708 1.8017 2.3562 -0.1533 3.1416 -0.9268

• Do you have a small numerical example? Commented May 19, 2014 at 8:57
• The red points look fine to me, exactly what I'd have expected to see with that data. What do you think it should look like? Commented May 19, 2014 at 9:56
• well, it certainly looks good. The problem, if we may call it so, is that the fitted parameters represents a gaussian that is by far larger than the x-axis. Thus the fit consists of the tip of a very wide gaussian that exceeds the domain of my data. Commented May 19, 2014 at 10:08
• I presume you mean "the range of my x's" rather than the x-axis (which is infinite!). Yes, it's wider, but that's what the data look like! If it's a Gaussian, it's a very wide Gaussian. Are you after some form of constrained optimization? Commented May 19, 2014 at 11:08
• as the title says, an alternative to "constrained optimization". I am just wondering what are the best ways to obtain shrinkage on parameters estimated during a non-linear Gaussian fitting procedure. An increase in the sigma parameter provides a good fit, however with the expense of the fit not being interpretable. Commented May 19, 2014 at 11:17