Go to the documentation of this file.
30 using namespace gtsam;
47 X &
Y &
Z,
"0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
52 std::vector<double> probs{0.2, 0.5, 0.3, 0.6, 0.4, 0.7, 0.25, 0.55, 0.35, 0.65, 0.45, 0.75};
71 X &
Y &
Z,
"0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
105 EXPECT(DiscreteConditional::CheckInvariants(dc,
values));
119 EXPECT(DiscreteConditional::CheckInvariants(C_given_DE, given));
134 for (
auto&& actual : {
prior * conditional, conditional *
prior}) {
136 KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
138 for (
auto&& it : actual.enumerate()) {
155 for (
auto&& actual : {A_given_B * B_given_C, B_given_C * A_given_B}) {
158 KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
160 for (
auto&& it : actual.enumerate()) {
175 for (
auto&& actual : {A_given_B * B_given_C, B_given_C * A_given_B}) {
178 KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
180 for (
auto&& it : actual.enumerate()) {
197 for (
auto&& actual : {AB_given_D * C_given_DE, C_given_DE * AB_given_D}) {
200 KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
202 KeyVector parents(actual.beginParents(), actual.endParents());
204 for (
auto&& it : actual.enumerate()) {
272 auto actual1 = C_given_DE.
choose(given);
277 auto actual2 = C_given_DE.
choose(given);
285 auto actual3 = C_given_DE.
choose(given);
304 string actual = conditional.
markdown();
321 DecisionTreeFactor::Names
names{{
x1, {
"A0",
"A1",
"A2"}}};
331 A |
B =
"2/88/10 2/20/78 33/33/34 33/33/34 95/2/3");
335 "|:-:|:-:|:-:|:-:|\n"
336 "|0|0.02|0.88|0.1|\n"
337 "|1|0.02|0.2|0.78|\n"
338 "|2|0.33|0.33|0.34|\n"
339 "|3|0.33|0.33|0.34|\n"
340 "|4|0.95|0.02|0.03|\n";
341 string actual = conditional.
markdown();
353 "|:-:|:-:|:-:|:-:|\n"
355 "|-|One|0.25|0.75|\n"
357 "|+|Zero|0.75|0.25|\n"
360 vector<string> keyNames{
"C",
"B",
"A"};
362 DecisionTreeFactor::Names
names{
363 {0, {
"Zero",
"One",
"Two"}}, {1, {
"-",
"+"}}, {2, {
"T",
"F"}}};
375 "<p> <i>P(A|B,C):</i></p>\n"
376 "<table class='DiscreteConditional'>\n"
378 " <tr><th><i>B</i></th><th><i>C</i></th><th>T</th><th>F</th></tr>\n"
381 " <tr><th>-</th><th>Zero</th><td>0</td><td>1</td></tr>\n"
382 " <tr><th>-</th><th>One</th><td>0.25</td><td>0.75</td></tr>\n"
383 " <tr><th>-</th><th>Two</th><td>0.5</td><td>0.5</td></tr>\n"
384 " <tr><th>+</th><th>Zero</th><td>0.75</td><td>0.25</td></tr>\n"
385 " <tr><th>+</th><th>One</th><td>0</td><td>1</td></tr>\n"
386 " <tr><th>+</th><th>Two</th><td>1</td><td>0</td></tr>\n"
390 vector<string> keyNames{
"C",
"B",
"A"};
392 DecisionTreeFactor::Names
names{
393 {0, {
"Zero",
"One",
"Two"}}, {1, {
"-",
"+"}}, {2, {
"T",
"F"}}};
static int runAllTests(TestResult &result)
double logProbability(const DiscreteValues &x) const
Log-probability is just -error(x).
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EXPECT_LONGS_EQUAL(expected, actual)
#define EXPECT(condition)
const KeyFormatter & formatter
double f2(const Vector2 &x)
const EIGEN_DEVICE_FUNC LogReturnType log() const
std::vector< double > Row
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
FACTOR::const_iterator endParents() const
DiscreteConditional marginal(Key key) const
FACTOR::const_iterator endFrontals() const
FACTOR::const_iterator beginFrontals() const
const_iterator end() const
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
DecisionTreeFactor::shared_ptr likelihood(const DiscreteValues &frontalValues) const
const gtsam::Symbol key('X', 0)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
FACTOR::const_iterator beginParents() const
Point2 prior(const Point2 &x)
Prior on a single pose.
double evaluate(const DiscreteValues &values) const
Evaluate, just look up in AlgebraicDecisonTree.
Matrix< Scalar, Dynamic, Dynamic > C
std::pair< Key, size_t > DiscreteKey
Array< int, Dynamic, 1 > v
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
shared_ptr choose(const DiscreteValues &given) const
< DiscreteValues version
TEST(DiscreteConditional, constructors)
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Marginals marginals(graph, result)
std::uint64_t Key
Integer nonlinear key type.
Frontals frontals() const
static const T & choose(int layout, const T &col, const T &row)
double error(const DiscreteValues &values) const
Calculate error for DiscreteValues x, is -log(probability).
gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:42