Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem in
CoreTest.testMahalanobisis that the generated covariance matrix is not invertible, because the random matrix has too few samples.Consider 3 vectors in 3D space. They all lie on a plane, so they can be expressed as their mean + 2 linearly independent vectors. This makes their covariance matrix singular. The same applies to n ≠ 3. You can verify this by observing that in
you will for any
nalways get a zero eigenvalue (actually close to zero due to numerical errors).The inverses in #24348 are different across platforms because, well, the inverse doesn't exist up to numerical errors. The fix is to add one more random sample to make the covariance matrix non-singular.
This PR resolves #24348
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.