commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom Brown <>
Subject Re: [math] Usage of Marquardt Optimizer for an Equation
Date Wed, 09 Sep 2015 16:45:51 GMT

I think I'm beginning to understand now (thanks to your awesome
explanations). Yes, wow, calculating the derivatives of F(t) wrt to the
parameters isn't that hard. I thought way too complicated, I'm afraid.

Now I'm just unsure about one thing:

> [Since the model "F(t)" refers to earlier times, I guess that you'll have
> to create a specific class in order to look up the correct "S", "b" and
> "I".]
After thinking about it, do you mean I should solve my problem like that:

MultivariateJacobianFunction distanceToCurrentF = new
MultivariateJacobianFunction() {
      public Pair<RealVector, RealMatrix> value(final RealVector params) {

          Vector3D approx = new Vector3D(params.getEntry(0),
params.getEntry(1), params.getEntry(2)); //get current estimations of
alpha, beta and gamma

          RealVector value = new ArrayRealVector(observedValues.length);
          RealMatrix jacobian = new
Array2DRowRealMatrix(observedValues.length, 3); // can I even use
Array2DRowRealMatrix if I have 3 columns?

          for (int i = 0; i < observedValues.length; ++i) {
              Vector o = observedValues[i];

              // calculate current values using helper.calculate...();
              double modelF = (helper.getCurrentS() +
helper.getCurrentB()) * helper.getCurrentI(i);
              value.setEntry(i, modelF);

              jacobian.setEntry(i, 0, derivative of dF/dalpha);
              jacobian.setEntry(i, 1, derivative of dF/dbeta);
              jacobian.setEntry(i, 2, derivative of dF/dgamma);

          return new Pair<RealVector, RealMatrix>(value, jacobian);


Is that somehow correct? I'm unsure because in the example were vectors
used for geometrical points and thus, I'm wondering if I can use an
Array2DRowRealMatrix or if I need something else?

And as for the optimization step:

double[] prescribedValues = new double[observedValues.length];
  Arrays.fill(prescribedValues, alpha, beta, gamma); // this will not
work, because I cannot use Arrays.fill() with two additional
parameters, what else should I use here? As in: what else can I use to
process my target?

  // least squares problem to solve : modeled radius should be close
to target radius
  LeastSquaresProblem problem = new LeastSquaresBuilder().
                                start(new double[] { 0.0, 1.0 } /* I
suppose I cannot add two further double arrays representing beta and
gamma in that way? Do I need a RealVector instead? Like a RealVector
that contains three Real Vector with the boundaries for alpha, beta
and gamma?*/).

LeastSquaresOptimizer.Optimum optimum = new

I hope this gets formatted in a readable way as my posts are somewhat
strangely formatted after submitting them. :P

Thanks again for answering my questions and giving me all that input! It's
highly appreciated.

Best regards

PS: sorry for my rough English, I'm obviously struggling along with finding
the best/right terms describing mathematical issues. :P

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message