I think I've answered my own question. I found a reference for turning a weighted least squares problem into an ordinary least squares problem. See section 1.2.4 WLS as OLS
in "Least Squares Adjustment: Linear and Nonlinear Weighted Regression Analysis" by Allan Aasbjerg Nielsen available at www2.imm.dtu.dk/pubdb/views/edoc_download.php/2804/pdf/imm2804.pdf
. The notation is slightly different, but in ejml terms, to solve a WLS problem, create an mxm diagonal matrix P where the diagonal contains sqrt(weight) and then pre-multiply both the A and y terms by P and then solve the new problem as an OLS.
P = CommonOps.diag(double ... weight), I use weight[i] = sqrt(1/(error in y[i]))
C = CommonOps.mult(P, A, C)
z = CommonOps.mult(P, y, z)
and then use a linear solver to solve C * x = z for x.
On Saturday, November 19, 2016 at 7:32:18 PM UTC-5, Walter Whitlock wrote:
I am able to use the LinearSolverFactory.leastSquares() solver to solve my problem. So far so good.
But my data vary over several orders of magnitude so I wantto weight the fit error by 1/(error in data).