# LeastSquaresProblem weight normalization

Hi everyone,
I wish to use the excellent LeastSquaresProblem with weights, and I would like to know if the weights need to be normalized. For example, given an array of weights

1. Should the sum of all the weights add up to 1.0?
2. Or, should all the weights be divided by the average weight (the weights would then add up to N, the number of weights in the list.)

I assume the correct way to add the weights is then :

LeastSquaresBuilder builder = new LeastSquaresBuilder();
builder.weight(new DiagonalMatrix(weights));

Thanks again, John

As far as I know, the weights are just applied directly as a multiplicative factor. So if you put the same weights on all observations, it is almost a no-op as all residuals would be multiplied by the same value. What is important is when you have different weights for different observations.

One traditional use of weights is to combine observations that have different units (say some represent angles in radians while other represent positions in meters).