Removed obsolete normalizationConstants method
parent
4283925e60
commit
b494a61150
|
@ -174,18 +174,6 @@ KeyVector GaussianMixture::continuousParents() const {
|
||||||
return continuousParentKeys;
|
return continuousParentKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
boost::shared_ptr<DecisionTreeFactor> GaussianMixture::normalizationConstants()
|
|
||||||
const {
|
|
||||||
DecisionTree<Key, double> constants(
|
|
||||||
conditionals_, [&](const GaussianConditional::shared_ptr &conditional) {
|
|
||||||
return conditional->normalizationConstant();
|
|
||||||
});
|
|
||||||
// If all constants the same, return nullptr:
|
|
||||||
if (constants.nrLeaves() == 1) return nullptr;
|
|
||||||
return boost::make_shared<DecisionTreeFactor>(discreteKeys(), constants);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
bool GaussianMixture::allFrontalsGiven(const VectorValues &given) const {
|
bool GaussianMixture::allFrontalsGiven(const VectorValues &given) const {
|
||||||
for (auto &&kv : given) {
|
for (auto &&kv : given) {
|
||||||
|
|
|
@ -160,10 +160,6 @@ class GTSAM_EXPORT GaussianMixture
|
||||||
/// log-normalization constants.
|
/// log-normalization constants.
|
||||||
double logNormalizationConstant() const override { return logConstant_; }
|
double logNormalizationConstant() const override { return logConstant_; }
|
||||||
|
|
||||||
/// Return a discrete factor with possibly varying normalization constants.
|
|
||||||
/// If there is no variation, return nullptr.
|
|
||||||
boost::shared_ptr<DecisionTreeFactor> normalizationConstants() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a likelihood factor for a Gaussian mixture, return a Mixture factor
|
* Create a likelihood factor for a Gaussian mixture, return a Mixture factor
|
||||||
* on the parents.
|
* on the parents.
|
||||||
|
|
|
@ -61,9 +61,6 @@ const GaussianMixture mixture({Z(0)}, {X(0)}, {mode}, conditionals);
|
||||||
TEST(GaussianMixture, Invariants) {
|
TEST(GaussianMixture, Invariants) {
|
||||||
using namespace equal_constants;
|
using namespace equal_constants;
|
||||||
|
|
||||||
// Check that normalizationConstants returns nullptr, as all constants equal.
|
|
||||||
CHECK(!mixture.normalizationConstants());
|
|
||||||
|
|
||||||
// Check that the mixture normalization constant is the max of all constants
|
// Check that the mixture normalization constant is the max of all constants
|
||||||
// which are all equal, in this case, hence:
|
// which are all equal, in this case, hence:
|
||||||
const double K = mixture.logNormalizationConstant();
|
const double K = mixture.logNormalizationConstant();
|
||||||
|
@ -170,19 +167,6 @@ TEST(GaussianMixture, ContinuousParents) {
|
||||||
EXPECT(continuousParentKeys[0] == X(0));
|
EXPECT(continuousParentKeys[0] == X(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
/// Check we can create a DecisionTreeFactor with all normalization constants.
|
|
||||||
TEST(GaussianMixture, NormalizationConstants) {
|
|
||||||
using namespace mode_dependent_constants;
|
|
||||||
|
|
||||||
const auto factor = mixture.normalizationConstants();
|
|
||||||
|
|
||||||
// Test with 1D Gaussian normalization constants for sigma 0.5 and 3:
|
|
||||||
auto c = [](double sigma) { return 1.0 / (sqrt(2 * M_PI) * sigma); };
|
|
||||||
const DecisionTreeFactor expected({M(0), 2}, {c(0.5), c(3)});
|
|
||||||
EXPECT(assert_equal(expected, *factor));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
/// Check that the likelihood is proportional to the conditional density given
|
/// Check that the likelihood is proportional to the conditional density given
|
||||||
/// the measurements.
|
/// the measurements.
|
||||||
|
|
Loading…
Reference in New Issue