Understanding the management of Measurement in the BatchLSEstimator and the computation of residuals

Hi @luca123,

Yes!
If you want to go further, in the LMS of Orekit, the residuals and Jacobian matrix are computed in the method AbstractBatchLSModel.fetchEvaluatedMeasurement.
Here the value vector contains the weighted residuals for a given evaluation, and the jacobian matrix contains the weighted Jacobian matrix

It’s funny you’re asking that because I just sent some classes to perform residuals computation in this post.

That being said it will just give you the residuals at iteration 0 (before the LMS filter starts working towards a solution).
If you want to have them at each iteration, you will have to extract them from a BatchLSObserver
There is an example of an implementation of such an observer: OrbitDeterminationObserver in the Java tutorials.
Note that this one doesn’t save the residuals at each iteration, you will have to do this by yourself.

Method evaluationPerfomed is called after each evaluation of the filter.
In this method, the EvaluationProviders variable can be called in a loop to retrieve each EstimatedMeasurement and perform residuals’ computation (see the loop at line 121 of the example).
Then calling:

residual[i] = estimatedMeasurement.getEstimatedValue()[i] - estimatedMeasurement.getObservedValue()[i]

on each component of your observations will give you the residuals.

Usage of the observer:

// Suppose you have a fully configured BatchLSEstimator
BatchLSEstimator estimator;

// Instantiate your custom observer with inputs [my_inputs]
// Suppose your observer save the residuals at each evaluation in an internal attribute
BatchLSObserver myObserver = new MyCustomObserver([my_inputs])

// Add it to the estimator
estimator.setObserver(myObserver);

// Then estimate
estimator.estimate();

After the process of estimation, if you have saved the residuals in the observer, you will just have to extract them.

Hope this helps,
Maxime

1 Like