Go to the documentation of this file.
34 using namespace gtsam;
44 std::make_shared<DiscreteConditional>(
m,
"60/40");
67 TEST(GaussianMixture, GaussianMixtureModel) {
68 double mu0 = 1.0, mu1 = 3.0;
79 double midway = mu1 - mu0;
80 auto eliminationResult =
82 auto pMid = *eliminationResult->
at(0)->asDiscrete();
86 for (
const double shift : {-4, -2, 0, 2, 4}) {
87 const double z = midway + shift;
91 auto eliminationResult1 =
93 auto posterior1 = *eliminationResult1->
at(0)->asDiscrete();
102 auto posterior2 = *eliminationResult2->at(0)->asDiscrete();
111 TEST(GaussianMixture, GaussianMixtureModel2) {
112 double mu0 = 1.0, mu1 = 3.0;
113 double sigma0 = 8.0,
sigma1 = 4.0;
134 auto eliminationResultMax = gfg.eliminateSequential();
139 eliminationResultMax->discretePosterior(
vv)));
141 auto pMax = *eliminationResultMax->at(0)->asDiscrete();
145 for (
const double shift : {-4, -2, 0, 2, 4}) {
146 const double z = zMax + shift;
150 auto eliminationResult1 =
152 auto posterior1 = *eliminationResult1->
at(0)->asDiscrete();
161 auto posterior2 = *eliminationResult2->at(0)->asDiscrete();
static int runAllTests(TestResult &result)
double Gaussian(double mu, double sigma, double z)
Gaussian density function.
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Eigen::Matrix< double, 1, 1 > Vector1
Conditional Gaussian Base class.
A hybrid conditional in the Conditional Linear Gaussian scheme.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EXPECT(condition)
A Bayes net of Gaussian Conditionals indexed by discrete keys.
static const VectorValues vv
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
static const double sigma
const sharedFactor at(size_t i) const
static ConjugateGradientParameters parameters
A conditional of gaussian conditionals indexed by discrete variables, as part of a Bayes Network....
Jet< T, N > pow(const Jet< T, N > &f, double g)
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
specialized key for discrete variables
std::shared_ptr< This > shared_ptr
shared_ptr to this class
AlgebraicDecisionTree< Key > discretePosterior(const VectorValues &continuousValues) const
Compute normalized posterior P(M|X=x) and return as a tree.
double prob_m_z(double mu0, double mu1, double sigma0, double sigma1, double z)
void push_back(std::shared_ptr< HybridConditional > conditional)
Add a hybrid conditional using a shared_ptr.
DiscreteConditional::shared_ptr mixing
Linearized Hybrid factor graph that uses type erasure.
TEST(SmartFactorBase, Pinhole)
const DiscreteValues m1Assignment
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
std::pair< Key, size_t > DiscreteKey
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
const DiscreteKey m(M(0), 2)
HybridGaussianFactorGraph toFactorGraph(const VectorValues &measurements) const
Jet< T, N > sqrt(const Jet< T, N > &f)
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
void emplace_shared(Args &&...args)
Matrix< RealScalar, Dynamic, Dynamic > M
gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:40:02