No juice. Hell! The initial function I'm trying to fit is: f(t, a, b, c) = a * t^b * exp(t*-c)
I had the log of it to make it linear: f(t, a, b, c) = log(a) + b*log(t) - c*t I was using the log to do the fitting in python with scipy. With CurveFitter should I do the same? > Date: Thu, 5 Jul 2012 22:18:04 +0200 > From: [email protected] > To: [email protected] > Subject: Re: [math] > > On Thu, Jul 05, 2012 at 06:16:11PM +0000, Italo Maia wrote: > > > > Some "context" below: > > > > Did you have a look at the classes in the package > > > > "org.apache.commons.math3.optimization" ? > > > > No, I did not. Let's see... > > > > > > Which function? > > > > This little devil: > > > > http://dpaste.com/hold/767050/ > > > > public static double fnc(double t, double a, double b, double c){ > > return Math.log(a) + b * Math.log(t) - c * t; > > > > } > > > > I have t in the matrix (first column). Second column are the observed > > values. I need to fit a, b and c. > > === END > > > > Well, the derivatives don't seem to be working. > > > > double da = 1/a; > > double db = b/t; > > double dc = -c; > > > > Then try > 1/a > log(t) > -t > > > Regards, > Gilles > > > > > > Date: Thu, 5 Jul 2012 19:21:46 +0200 > > > From: [email protected] > > > To: [email protected] > > > Subject: Re: [math] > > > > > > Hi. > > > > > > > > > > > Thanks Giles! I was looking in the wrong place. Any suggestions on > > > > examples for these classes (a math function example would be very > > > > nice)? I've found this link (very helpful) but I don't know what to > > > > code in the gradient method. In ParametricUnivariateFunction.value I > > > > just returned my function output with the params as arguments (plus x). > > > > For gradient, I'm in a pitch. > > > > > > And I'm lacking context (sorry, I deleted your previous email from my > > > inbox)... > > > > > > Anyways, the "gradient(double x, double ... parameters)" method should > > > return the partial derivatives with respect to the _parameters_. So, for > > > example: > > > --- > > > public class ParamFuncExample implements ParametricUnivariateFunction { > > > public double value(double x, double ... p) { > > > return p[0] * x + p[1]; > > > } > > > > > > public double[] gradient(double x, double ... p) { > > > return new double[] { x, 1 }; > > > } > > > } > > > --- > > > > > > > > > HTH, > > > Gilles > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >
