idaholab / raven

RAVEN is a flexible and multi-purpose probabilistic risk analysis, validation and uncertainty quantification, parameter optimization, model reduction and data knowledge-discovering framework.
https://raven.inl.gov/
Apache License 2.0
217 stars 133 forks source link

Implements a multivariate normal distribution #2223

Closed j-bryan closed 8 months ago

j-bryan commented 9 months ago

Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

Closes #2222

What are the significant changes in functionality due to this change request?

Implements a multivariate normal distribution in python that uses scipy.stats.multivariate_normal and scipy.stats.norm classes as a backend.


For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

moosebuild commented 8 months ago

Job Test qsubs sawtooth on 415048b : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

moosebuild commented 8 months ago

Job Test qsubs sawtooth on 04f284a : invalidated by @j-bryan

Failed with DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

j-bryan commented 8 months ago

The last several commits, starting with this commit, add a Crow MultivariateNormalDistribution object to the constructor of the MultivariateNormalPCA class added by this pull request to check the results of the SVD of the covariance matrix of the distribution against the existing Crow implementation. This is done for now as a way to check the remainder of the implemented code. The idea here is that if inconsistencies in the SVD (e.g. signs in the U and V matrices that are not unique) are the only discrepancy between my added class and the Crow implementation, all of the tests should pass as long as the Crow classes SVD matrices are used. Rather than replace the entire matrices calculated by the RAVEN python code, I only adjust the signs of the left and right singular vectors to match those from the Crow SVD.

After applying this sign correction, there are three tests that are failing across the test machines:

  1. tests/framework/MCMC/MetropolisTenDimMVN
  2. tests/framework/MCMC/MetropolisTenDimPropMVN
  3. tests/framework/pca_sparseGridCollocation/attenuCorrelation

The decomposed covariance matrix in the MetropolisTenDimMVN contains several repeated singular values, and the order of their associated vectors is not consistent between my implementation and the Crow result. Something similar happens with the MetropolisTenDimPropMVN test, but the covariance matrix in question has many more repeated singular values (9 of the 10). The vector associated with the unique singular value matches between implementations but the remaining vectors from the repeated singular values do not. This is not too surprising though, since eigenvalues of multiplicity greater than 1 do not have unique eigenvectors. Both implementations produce a valid SVD. Finally, the attenuCorrelation test is failing with a very small diff in an output XML file (difference only in the 8th or 9th significant digit). I believe this may be stemming from small numerical differences in the SVD results between implementations. I believe this test is still working as intended but needs either a regold or a tolerance added to the test.

While this isn't as nice as a script showing that the tests aren't diffing, I do believe this shows that the added code is working as intended, and the diffs in the failing tests that occur when the Crow SVD sign convention is not used are the result only of that difference in sign. @joshua-cogliati-inl, in your opinion, is this thorough enough to green light regolding effected tests?

moosebuild commented 8 months ago

Job Test qsubs sawtooth on 972af8b : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

moosebuild commented 8 months ago

Job Test qsubs sawtooth on e1eab7f : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

moosebuild commented 8 months ago

Job Mingw Test on e1eab7f : invalidated by @joshua-cogliati-inl

failed in fetch

moosebuild commented 8 months ago

Job Mingw Test on e1eab7f : invalidated by @j-bryan

Error when fetching Raven

moosebuild commented 8 months ago

Job Test qsubs sawtooth on e1eab7f : invalidated by @joshua-cogliati-inl

FAILED: Diff tests/cluster_tests/test_mpiqsub_long

moosebuild commented 8 months ago

Job Test qsubs sawtooth on e1eab7f : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

moosebuild commented 8 months ago

Job Test qsubs sawtooth on e1eab7f : invalidated by @joshua-cogliati-inl

Failed with: DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.

moosebuild commented 8 months ago

Job Test qsubs sawtooth on e1eab7f : invalidated by @j-bryan

Something broke but results won''t load. Same error as before? Trying again.