add HybridGaussianFactorGraph::probPrime method
parent
cb55af3a81
commit
eb94ad90d2
|
|
@ -511,6 +511,14 @@ double HybridGaussianFactorGraph::error(
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
|
double HybridGaussianFactorGraph::probPrime(
|
||||||
|
const VectorValues &continuousValues,
|
||||||
|
const DiscreteValues &discreteValues) const {
|
||||||
|
double error = this->error(continuousValues, discreteValues);
|
||||||
|
return std::exp(-error);
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
AlgebraicDecisionTree<Key> HybridGaussianFactorGraph::probPrime(
|
AlgebraicDecisionTree<Key> HybridGaussianFactorGraph::probPrime(
|
||||||
const VectorValues &continuousValues) const {
|
const VectorValues &continuousValues) const {
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,18 @@ class GTSAM_EXPORT HybridGaussianFactorGraph
|
||||||
AlgebraicDecisionTree<Key> probPrime(
|
AlgebraicDecisionTree<Key> probPrime(
|
||||||
const VectorValues& continuousValues) const;
|
const VectorValues& continuousValues) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Compute the unnormalized posterior probability for a continuous
|
||||||
|
* vector values given a specific assignment.
|
||||||
|
*
|
||||||
|
* @param continuousValues The vector values for which to compute the
|
||||||
|
* posterior probability.
|
||||||
|
* @param discreteValues The specific assignment to use for the computation.
|
||||||
|
* @return double
|
||||||
|
*/
|
||||||
|
double probPrime(const VectorValues& continuousValues,
|
||||||
|
const DiscreteValues& discreteValues) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compute the VectorValues solution for the continuous variables for
|
* @brief Compute the VectorValues solution for the continuous variables for
|
||||||
* each mode.
|
* each mode.
|
||||||
|
|
|
||||||
|
|
@ -581,7 +581,7 @@ TEST(HybridGaussianFactorGraph, ErrorAndProbPrime) {
|
||||||
EXPECT(assert_equal(expected_error, error, 1e-9));
|
EXPECT(assert_equal(expected_error, error, 1e-9));
|
||||||
|
|
||||||
double probs = exp(-error);
|
double probs = exp(-error);
|
||||||
double expected_probs = exp(-expected_error);
|
double expected_probs = graph.probPrime(delta.continuous(), delta.discrete());
|
||||||
|
|
||||||
// regression
|
// regression
|
||||||
EXPECT(assert_equal(expected_probs, probs, 1e-7));
|
EXPECT(assert_equal(expected_probs, probs, 1e-7));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue