Skip to content

Commit ea74979

Browse files
committed
Add factor of 2.0 to covariance calculation to compensate for 1/2 in objective function
1 parent 8bc80ad commit ea74979

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Numerics/Optimization/NonlinearMinimizationResult.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ void EvaluateCovariance(IObjectiveModel objective)
5757
return;
5858
}
5959

60-
Covariance = Hessian.PseudoInverse() * objective.Value / objective.DegreeOfFreedom;
60+
// The factor of 2.0 compensates for the 1/2 factor in the objective function definition
61+
// F(p) = 1/2 * ∑{ Wi * (yi - f(xi; p))^2 }
62+
// Without this compensation, the covariance and standard errors would be underestimated by a factor of 2
63+
Covariance = 2.0 * Hessian.PseudoInverse() * objective.Value / objective.DegreeOfFreedom;
6164

6265
if (Covariance != null)
6366
{

0 commit comments

Comments
 (0)