Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#37 AGaussianFactorLearningEngine fails for some random seeds

open
nobody
None
5
2007-09-12
2007-09-12
Brian Milch
No

The "make check" command runs a test called AGaussianFactorLearningEngine, which fails on my machine (64-bit Debian with gcc 4.1.2). An inverse covariance matrix ends up being non-symmetric at pnlGaussianDistribFun.cpp:586. The error only occurs for some randomly generated training data: one way to reproduce it is to call
pnlSeed(1189533220)
at the beginning of testGaussianFactorLearningEngine in c_pgmtk/tests/src/AGaussianParameterLearning.cpp.

The bug appears to be due to floating-point imprecision. In CGaussianDistribFun::ConvertCPDDistribFunToPot, in lines 6291-6301, the inverse covariance matrix invCovMat is combined with the matrix matMinusWeights in the form:
matMinusWeightsTranspose * (invCovMat * matMinusWeights)
I've checked that invCovMat is symmetric, so the result of this should also be symmetric. But for the seed given above, two entries in the result that should be equal end up differing by 3.51 x 10^-3. This is a bit more than the threshold passed to IsSymmetric, which is 1 x 10^-3.

There are several possible ways to fix this.
1) Just pass a weaker threshold to IsSymmetric.
2) Use double-precision arithmetic in pnlMultiply.
3) Use a special function to compute matrix products of the form B'AB where A is symmetric, exploiting the fact that the result will be symmetric.
4) Correct asymmetries by averaging elements that should be equal.

Discussion