Package edu.cnu.mdi.splot.fit
Class LinearLeastSquaresGuesser
java.lang.Object
edu.cnu.mdi.splot.fit.LinearLeastSquaresGuesser
Utility for computing a weighted linear least-squares parameter guess: min
sum_i w_i (A_i p - y_i)^2 by solving (sqrt(W)A)p = sqrt(W)y via QR.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]solve(double[][] A, double[] y, double[] weights) Solve for parameters p in a linear model y ≈ A p using (optionally) weights.
-
Method Details
-
solve
public static double[] solve(double[][] A, double[] y, double[] weights) Solve for parameters p in a linear model y ≈ A p using (optionally) weights. Rows are scaled by sqrt(weight_i) for WLS.- Parameters:
A- design matrix (n x p)y- target vector (n)weights- optional weights (n) or null for OLS- Returns:
- parameter vector p (length p). Returns zeros if solve fails.
-