# commons-user mailing list archives

##### Site index · List index
Message view
Top
From Thom Brown <thomas.braunsber...@gmail.com>
Subject Re: [math] Usage of Marquardt Optimizer for an Equation
Date Wed, 09 Sep 2015 08:15:56 GMT
```Hi,

So, if you have N observations (indexed by the time variable), you'll have
> 3 * N measurements. And the "target" will be for example:
>
>  [S(t0), b(t0), I(t0), S(t1), b(t1), I(t1), ..., S(tN), b(tN), I(tN)]
>

That means I have to specify a vector for each t? Like in the example, but
instead of x,y coordinates of a point I need to use S, b, I? What I haven't
realized by the time I asked the question is that the fourth equation for
the prediction is also essential. I do not need a forecast per se, but by
calculating F(t) = (S(t) + b(t)) * I(t-L) I get the new value of X(t). So,
the vector would contain (S(t), b(t), I(t), F(t) and what about X(t), which
is the real observation?

Basically I need only an approximation for alpha, beta and gamma, so I
thought I would use the first two periods, i.e., [S(L), b(L), I(L), F(L),
..., S(L+L), b(L+L), I(L+L), F(L+L)]. What still confuses me is that I'm
not sure if I can simple process the parameters this way. In order to
calculate the parameters for t = L I need the initial parameters (I can
provide them). But do I then have to use a set of [S(L-1), b(L-1), I(L-1),
F(L-1), S(L), b(L), ..., I(L+L)]? And how can I make sure that S(L-1), ...,
will not be part of the optimization?

Basically the minimum I'm searching for is SUM((F(i) - X(i))^2) / 2L (just
the MSE). Do I have to put that in the jacobian matrix via setEntry()?

You must provide the Jacobian (in the "model" function), i.e. a matrix where
> each line corresponds to a measurement, and the columns must be the partial
> derivatives wrt the parameters (i.e. "alpha", "beta" and "gamma").

Which makes me want to answer my previous question with no, however, where
else do I specify the MSE calculation? And then again, I'm wondering: does
my matrix consist of 5 columns? {X(i), S(i), b(i), I(i), F(i)}? Or do I
have to create one equation where I put all my parameters in (I'm not sure
I'm able to do such a thing :P).

My main problem is that I obviously fail to understand on how to use such a
optimizer. I have four equations and so far I have only seen on how to use
it on a rather simple example. That leaves me with the question on how to
specify four different equations in the same Jacobian?

jacobian.setEntry(i, 0, -equation for S(t)-);
jacobian.setEntry(i, 1, -equation for b(t)-);
jacobian.setEntry(i, 2, -equation for I(t)-);
jacobian.setEntry(i, 3, -equation for F(t)-);

Just like that? Ohh.. I think I understand ... so that's where I have to
put the derivatives for each equation? And via jacobian.setEntry(i, ((F(i)
- X(i))^2) I provide the minimization I'm looking for?

> Why would you, since the derivatives are relatively easy to provide?

The derivative for S(t)/d(alpha) would be -b(t-1) - S(t-1) - I(t-L) * X
then? Am I correct in that? I'm sorry for that math question instead of
focusing on the apache commons framework, but it would help me to