Resolve GaussianMixture error crisis

release/4.3a0
Frank Dellaert 2023-01-14 12:56:38 -08:00
parent ab439bfbb0
commit c9fcfe3299
2 changed files with 16 additions and 2 deletions

View File

@ -293,7 +293,7 @@ AlgebraicDecisionTree<Key> GaussianMixture::logProbability(
double GaussianMixture::error(const HybridValues &values) const {
// Directly index to get the conditional, no need to build the whole tree.
auto conditional = conditionals_(values.discrete());
return conditional->error(values.continuous());
return conditional->error(values.continuous()) - conditional->logNormalizationConstant();
}
/* *******************************************************************************/

View File

@ -176,7 +176,21 @@ class GTSAM_EXPORT GaussianMixture
/**
* @brief Compute the error of this Gaussian Mixture.
*
* log(probability(x)) = K - error(x)
* This requires some care, as different mixture components may have
* different normalization constants. Let's consider p(x|y,m), where m is
* discrete. We need the error to satisfy the invariant:
*
* error(x;y,m) = K - log(probability(x;y,m))
*
* For all x,y,m. But note that K, for the GaussianMixture, cannot depend on
* any arguments. Hence, we delegate to the underlying Gaussian
* conditionals, indexed by m, which do satisfy:
*
* log(probability_m(x;y)) = K_m - error_m(x;y)
*
* We resolve by having K == 0.0 and
*
* error(x;y,m) = error_m(x;y) - K_m
*
* @param values Continuous values and discrete assignment.
* @return double