On Wed, 9 Sep 2015 18:45:51 +0200, Thom Brown wrote:
> Hi!
>
> 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'd think so; that should be the idea. [But no warranty...]
> I'm unsure because in the example were vectors
> used for geometrical points and thus, I'm wondering if I can use an
> Array2DRowRealMatrix
Sure.
> 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?
Remember that "target" must contain the measurements (i.e. the
observed values of the model function "F"), not the parameters of
the model.
However, I'm not sure how everything plays out.
If I had to do the work, I'd take the case described there:
http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc436.htm
as a unit test.
> // 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?*/).
Yes, you have to have an "initial guess" for each of the parameters
of the model.
> model(distancesToCurrentF).
> target(prescribedValues).
> lazyEvaluation(false).
> maxEvaluations(1000).
> maxIterations(1000).
> build();
>
> LeastSquaresOptimizer.Optimum optimum = new
> LevenbergMarquardtOptimizer().optimize(problem);
>
> I hope this gets formatted in a readable way as my posts are somewhat
> strangely formatted after submitting them. :P
[I guess that it's because everything is aligned in a variablewidth
font, while the ML use a fixedwidth font.]
Best regards,
Gilles
> Thanks again for answering my questions and giving me all that input!
> It's
> highly appreciated.
>
> Best regards
> Thom
>
> PS: sorry for my rough English, I'm obviously struggling along with
> finding
> the best/right terms describing mathematical issues. :P

To unsubscribe, email: userunsubscribe@commons.apache.org
For additional commands, email: userhelp@commons.apache.org
