AbstractLeastSquaresOptimizer extends JacobianMultivariateVectorOptimizer { public double[] computeSigma(double[] params, double covarianceSingularityThreshold) { final int nC = params.length; final double[] sig = new double[nC]; final double[][] cov = computeCovariances(params, covarianceSingularityThreshold); for (int i = 0; i < nC; ++i) { sig[i] = FastMath.sqrt(cov[i][i]); } return sig; } protected  AbstractLeastSquaresOptimizer(ConvergenceChecker<PointVectorValuePair> checker); double getRMS(); double getChiSquare(); RealMatrix getWeightSquareRoot(); double[][] computeCovariances(double[] params,
                                         double threshold); double[] computeSigma(double[] params,
                                 double covarianceSingularityThreshold); @Override PointVectorValuePair optimize(OptimizationData... optData);  }
@Test public void testComputeSigma() throws IOException { final StatisticalReferenceDataset dataset = StatisticalReferenceDatasetFactory.createKirby2(); final AbstractLeastSquaresOptimizer optimizer = createOptimizer(); final double[] a = dataset.getParameters(); final double[] y = dataset.getData()[1]; final double[] w = new double[y.length]; Arrays.fill(w, 1); StatisticalReferenceDataset.LeastSquaresProblem problem = dataset.getLeastSquaresProblem(); final PointVectorValuePair optimum = optimizer.optimize(new MaxEval(1), problem.getModelFunction(), problem.getModelFunctionJacobian(), new Target(y), new Weight(w), new InitialGuess(a)); final double[] sig = optimizer.computeSigma(optimum.getPoint(), 1e-14); final int dof = y.length - a.length; final double[] expected = dataset.getParametersStandardDeviations(); for (int i = 0; i < sig.length; i++) { final double actual = FastMath.sqrt(optimizer.getChiSquare() / dof) * sig[i]; Assert.assertEquals(dataset.getName() + ", parameter #" + i, expected[i], actual, 1e-6 * expected[i]); } }