11-15-2020 12:27 AM
I understand that we can provide hard boundary conditions as min and max values of the fit variables in the non-linear curve fit VI; Say I have a model as the sum of 3 Gaussians, and I want to know how to give constraints like a1>a2>a3, where a1,a2,a3 are amplitudes of each Gaussian (also the fit variables).
I wanted to ensure that my 2nd gaussian will be of lower amplitude that first, similarly between 3rd and 2nd.
Solved! Go to Solution.
11-15-2020 10:17 AM
Am I correct that when you say "1st, 2nd, 3rd", you are referring to the X position of the peaks of these Gaussians?
One way that many non-linear fitting algorithms work is to compute a "Goodness-of-Fit" (which is often "Mean-Square Error") measure on a set of Parameters, and then try to converge the Parameter set to the region with lowest MSE. With the "added constraints" you are imposing, it gets a little messy, but I'd try something like the following:
You can also attempt to do all three peaks at once, starting with your three initial "guesses". The trick is to adjust the MSEs based on your constraints (1 < 2 < 3) before deciding which point is the "worst" (and/or the "best").
I learned (and used) this technique a few (oh, my goodness --) decades ago when I was coding up the Nelder-Mead Simplex algorithm (in Pascal!), where "constraints" were discussed. You might look up "Constraints in non-linear fitting algorithms" or something like that on the Web for a more authoritative suggestion.
Bob Schor
11-15-2020 01:00 PM - edited 11-15-2020 01:58 PM
@rahul_manoj wrote:
... give constraints like a1>a2>a3
You can re-parameterize your model and fit for transformed parameters, e.g. aa1, aa2, aa3 where:
aa1=a2-a1
aa2=a2
aa3=a3-a2
Now you can constrain aa1 and aa3 to be positive and your conditions are always fulfilled, independent of a2.