Go to the documentation of this file.
27 template class FactorGraph<DiscreteConditional>;
59 std::mt19937_64*
rng)
const {
65 const Key j = conditional->firstFrontalKey();
79 size_t maxNrLeaves,
const std::optional<double>& marginalThreshold,
86 pruned.
prune(maxNrLeaves);
91 if (marginalThreshold && pruned.
keys().size() > 0) {
97 auto threshold = (probabilities.array() > *marginalThreshold);
100 if (!threshold.isZero()) {
101 threshold.maxCoeff(&index);
105 deadModesValues.emplace(dkey.first, index);
114 *fixedValues = deadModesValues;
120 if (pruned.
keys().size() > 0)
result.push_back(pruned);
138 std::stringstream
ss;
139 ss <<
"`DiscreteBayesNet` of size " <<
size() << endl << endl;
141 ss << conditional->markdown(keyFormatter,
names) << endl;
149 std::stringstream
ss;
150 ss <<
"<div><p><tt>DiscreteBayesNet</tt> of size " <<
size() <<
"</p>";
152 ss << conditional->html(keyFormatter,
names) << endl;
bool equals(const This &bn, double tol=1e-9) const
static std::stringstream ss
DiscreteConditional joint() const
Multiply all conditionals into one big joint conditional and return it.
double logProbability(const DiscreteValues &values) const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
DiscreteBayesNet prune(size_t maxNrLeaves, const std::optional< double > &marginalThreshold={}, DiscreteValues *fixedValues=nullptr) const
Prune the Bayes net.
bool equals(const This &fg, double tol=1e-9) const
Check equality up to tolerance.
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
Render as markdown tables.
double evaluate(const DiscreteValues &values) const
A class for computing marginals in a DiscreteFactorGraph.
std::shared_ptr< This > shared_ptr
shared_ptr to this class
std::reverse_iterator< Iterator > make_reverse_iterator(Iterator i)
DiscreteValues::Names Names
Translation table from values to strings.
const KeyVector & keys() const
Access the factor's involved variable keys.
const_iterator end() const
DiscreteValues sample(std::mt19937_64 *rng=nullptr) const
do ancestral sampling
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
Render as html tables.
const_iterator begin() const
DiscreteKeys discreteKeys() const
Return all the discrete keys associated with this factor.
Marginals marginals(graph, result)
std::uint64_t Key
Integer nonlinear key type.
void removeDiscreteModes(const DiscreteValues &given)
Remove the discrete modes whose assignments are given to us. Only applies to discrete conditionals.
virtual void prune(size_t maxNrAssignments)
Prune the conditional.
gtsam
Author(s):
autogenerated on Wed May 28 2025 03:01:13