Open hdiedam opened 7 years ago
We have tests covering this function throughout the test suite. We could just swap the implementation and see if they are still working. I don't think speed improvement will be significant here since we do not calculate the covariate matrix very often. Improvement and stability however is well worth the change!
@hdiedam JacobianMatrix is an internal object of OSPSuite and does not have a method PseudoInverse().
Could you please check the code and let me know what should be implemented? Going to remove it from 7.3.0 for now
@hdiedam I guess I can simply create a Matrix object from .NET numeric filled with our matrix and go from there? It this what is meant?
Yes, I just assumed that JacobianMatrix was derived from Matrix, because the function returns a Matrix object and in line 81 you use "var fisherInv = fisher.PseudoInverse();". If JacobianMatrix itself is not a Matrix just create one using the underlying data array.
The code in calculateCovarianceMatrix can be improved.
In line with the original youtrack 47-7683: Although, the code used in this function currently is theoretically correct (because pinv(J'J)=inv(J'J)), it is numerically inferior and much more complex compared to the original suggestion. Using directly pinv(J)*S*pinv(J)', scalar times matrix multiplication instead of building the dense diagonal matrix and the API from https://numerics.mathdotnet.com/api/MathNet.Numerics.LinearAlgebra.Double/Matrix.htm should lead to (untestet):
which should be a significant stability,readability and speed improvement.
@Yuri05 @KatrinCoboeken