Thanks for your patience, maybe a better/simpler example would be [1], I want to find the best fit using LSB under the constraint that the height of the curve never is above 0.7 (even though without constrains the optimizer would find a better solution around 8.5).

So my first idea way to copy/extend GausianCurveFitter to accept some kind of "maxHeight(...)", adjust the function to return INF for h>maxHeight, I was just unsure that return INF is allowed (per definition) as it is not mentioned anywhere in the userdocs. And if I want to limit others (like max position) it would work the same way.

In my final problem I need to limit the height, width and position of the bell-curve to fall into certain bounds, but there is no direct relation (e.g. width must be three times the height).



[1] https://crlbucophysics101.files.wordpress.com/2015/02/gaussian.png?w=538&h=294




Am 11.08.20 um 11:18 schrieb Gilles Sadowski:
Hi.

2020-08-11 8:51 UTC+02:00, Christoph Läubrich <lae...@googlemail.com.invalid>:
Hi Gilles,


Just to make clear I don't suspect any error with GausianCurveFitter, I
just don't understand how the advice in the user-doc to restrict
parameter (for general problems) could be applied to a concrete problem
and thus chosen GausianCurvefitter as an example as it uses
LeastSquaresBuilder.

I also noticed that Gaussian Fitter has a restriction on parameters
(norm can't be negative) that is handled in a third way (returning
Double.POSITIVE_INFINITY instead of Parameter Validator) not mentioned
in the userdoc at all, so I wonder if this is a general purpose solution
for restricting parameters (seems the simplest approach).

I'd indeed suggest to first try the same trick as in "GaussianCurveFitter"
(i.e. return a "high" value for arguments outside a known range).
That way, you only have to define a suitable "ParametricUnivariateFunction"
and pass it to "SimpleCurveFitter".

One case for the "ParameterValidator" is when some of the model
parameters might be correlated to others.
But using it makes it necessary that you handle yourself all the
arguments to be passed to the "LeastSquaresProblem".

To take the gausian example for my use case, consider an observed signal
similar to [1], given I know (from other source as the plain data) for
example that the result must be found in the range of 2...3 and I wanted
to restrict valid solutions to this area. The same might apply to the
norm: I know it must be between a given range and I want to restrict the
optimizer here even though there might be a solution outside of the
range that (compared of the R^2) fits better, e.g. a gausian fit well
inside the -1..1.

I hope it is a little bit clearer.

I'm not sure.  The picture shows a function that is not a Gaussian.
Do you mean that you want to fit only *part* of the data with a
function that would not fit well *all* the data?

Regards,
Gilles



[1]
https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg

Am 11.08.20 um 00:42 schrieb Gilles Sadowski:
Hello.

Le lun. 10 août 2020 à 17:09, Christoph Läubrich
<lae...@googlemail.com.invalid> a écrit :

The userguide [1] mentions that it is currently not directly possible to
contrain parameters directly but suggest one can use the
ParameterValidator, is there any example code for both mentioned
alternatives?

For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
archive that the mean is within a closed bound e.g from 5 to 6 where my
datapoints ranges from 0..90, how would this be archived?

Could you set up a unit test as a practical example of what
you need to achieve?

I'm especially interested because the FUNCTION inside
GaussianCurveFitter seems to reject invalid values (e.g. negative
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
either approach described in the user-docs.

What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles



[1]
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to