diff --git a/src/Numerics/Optimization/IObjectiveModel.cs b/src/Numerics/Optimization/IObjectiveModel.cs
index 2409dffe..ff117091 100644
--- a/src/Numerics/Optimization/IObjectiveModel.cs
+++ b/src/Numerics/Optimization/IObjectiveModel.cs
@@ -6,6 +6,16 @@ namespace MathNet.Numerics.Optimization
{
IObjectiveModel CreateNew();
+ ///
+ /// Get the y-values of the observations.
+ ///
+ Vector ObservedY { get; }
+
+ ///
+ /// Get the values of the weights for the observations.
+ ///
+ Matrix Weights { get; }
+
///
/// Get the y-values of the fitted model that correspond to the independent values.
///
@@ -38,6 +48,11 @@ namespace MathNet.Numerics.Optimization
///
Matrix Covariance { get; }
+ ///
+ /// Get the correlation matrix.
+ ///
+ Matrix Correlation { get; }
+
///
/// Get the number of calls to function.
///
diff --git a/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs b/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs
index c5558f99..f1204189 100644
--- a/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs
+++ b/src/Numerics/Optimization/ObjectiveModels/FittingObjectiveModel.cs
@@ -123,6 +123,11 @@ namespace MathNet.Numerics.Optimization.ObjectiveModels
///
public Matrix Covariance { get; private set; }
+ ///
+ /// Get the correlation matrix.
+ ///
+ public Matrix Correlation { get; private set; }
+
///
/// Get the number of calls to function.
///
@@ -484,18 +489,23 @@ namespace MathNet.Numerics.Optimization.ObjectiveModels
EvaluateFunction(Pext);
EvaluateJacobian(Pext);
+ // restore isBounded
+ this.IsBounded = (LowerBound != null || UpperBound != null);
+
if (Hessian == null || Residuals == null || DegreeOfFreedom < 1)
{
Covariance = null;
+ Correlation = null;
return;
}
var covariance = Hessian.PseudoInverse() * Residuals.DotProduct(Residuals) / DegreeOfFreedom;
-
Covariance = covariance;
- // restore isBounded
- this.IsBounded = (LowerBound != null || UpperBound != null);
+ var correlation = covariance.Clone();
+ var d = correlation.Diagonal().PointwiseSqrt();
+ var dd = d.OuterProduct(d);
+ Correlation = correlation.PointwiseDivide(dd);
return;
}