commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject [Math] MATH-1172 (Was: [math] - Fitting curve with 6 parameters)
Date Tue, 25 Nov 2014 15:01:26 GMT
Hi.

On Mon, 24 Nov 2014 18:47:10 +0000, Michael Howard wrote:
> Hello!
>
> I am trying to estimate the parameters of a large number of curves.
> They are all instances of the generalized logistic function [...]
>
> I'm trying to do this with what is available in the commons library,
> but I can't make sense of how to accomplish it.
>
> First, there is actually already a implementation of the generalized
> logistic curve in the commons, under
> org.apache.commons.math3.analysis.function.Logistic.Parametric. The
> 'ParametricUnivariateFunction' class looks like it's intended for use
> with curve fitting algorithms, using subclasses of
> org.apache.commons.math3.fitting.AbstractCurveFitter. But, there 
> isn't
> an implementation which accepts Logistic. If I understand correctly, 
> I
> would have to code my own implementation of a curve fitting algorithm
> and have it extend AbstractCurveFitter.

That would be the simplest way to go, IMHO.
But I think that it is indeed more complicated than it could be for
simple uses (like in your case).

Thus I opened an issue on the bug-tracking system:
   https://issues.apache.org/jira/browse/MATH-1172

There you can find the Java code that would let a user to just pass
the "ParametricUnivariateFunction" which he wants to fit.

You could readily use it in your case as follows:
---CUT---
final WeightedObservedPoints obs = new WeightedObservedPoints();
// Add sample data to "obs"...

final ParametricUnivariateFunction logistic = new 
Logistic.Parametric();
final double[] guess = new double[] { /* initial values of the 
paramters */ };
final BasicCurveFitter fitter = BasicCurveFitter.create(logistic, 
guess);
final double[] params = fitter.fit(obs.toList());
---CUT---

[It will be discussed on the "dev" ML whether this code should be added
to Commons Math.]

Best regards,
Gilles

> [...]


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


Mime
View raw message