commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [math] Gaussian fitter stalls
Date Tue, 12 Jun 2012 17:57:04 GMT
On Tue, Jun 12, 2012 at 08:53:05AM -0700, B.Kumar wrote:
> Hi all!
> Has anyone had a chance to look at or think about this?
> Thanks!

When you ask for help, please provide a fully-working minimal example, in
the form of a Junit test. This will surely speed things up, both for us and
for you.
In this case, this means a function (say, "testMath798") to be inserted in
the test class for "GaussianFitter", to be found in
  src/test/java/org/apache/commons/math3/optimization/fitting/GaussianFitterTest.java
in the source code repository.

> 
> On 6/7/2012 8:05 AM, B.Kumar wrote:
> >Hi all!
> >This seems to be very similar to the one reported in
> >"https://issues.apache.org/jira/browse/MATH-798
> >-PolynomialFitter.fit() stalls".
> >When I call the Gaussian fitter.fit() with the following set of points:
> >x : y
> >0.23 : 395.00
> >0.68 : 0.00      <----
> >1.14 : 376.00
> >1.59 : 0.00      <----
> >2.05 : 163.00
> >2.50 : 0.00      <----
> >2.95 : 49.00
> >3.41 : 0.00      <----
> >3.86 : 16.00
> >4.32 : 0.00      <----
> >4.77 : 1.00
> >it never returns.
> >Thanks for looking into this as well.
> >B.Kumar
> 

I created the unit test, and indeed it doesn't find an answer.
And that's because of the data points which I marked with an arrow above.
If you plot the data, it is hard to expect that a Gaussian will fit them.
[The more so with the pretty stringent default convergence thresholds.]

If you loosen (a lot) the convergence criteria (e.g. by using an explicit
"SimpleVectorValueConvergenceChecker" with a relative tolerance of 1e-3),
the parameters are found to be
  p=[5001984.039785841, -23.740947813999718, 5.457232049164412]
I.e. your data is fitted by the tail of a very, very, very tall Gaussian.

I guess that it's not what you want.
More likely is that you should filter out the data so that only those points
that are "fairly well" approximated by a Gaussian remain. [This part is not
done by Commons Math.]
Thus (manually) removing those points in the above data set, the fit
produces:
  p=[420.8397296167364, 0.603770729862231, 1.0786447936766612]
even with very stringent tolerances (1e-15).


HTH,
Gilles

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


Mime
View raw message