Go to the documentation of this file.
27 template class FactorGraph<DiscreteConditional>;
64 const Key j = conditional->firstFrontalKey();
66 conditional->sampleInPlace(&
result);
78 size_t maxNrLeaves,
const std::optional<double>& marginalThreshold,
83 joint = joint * (*conditional);
87 pruned.
prune(maxNrLeaves);
92 if (marginalThreshold && pruned.
keys().size() > 0) {
98 auto threshold = (probabilities.array() > *marginalThreshold);
101 if (!threshold.isZero()) {
102 threshold.maxCoeff(&index);
106 deadModesValues.emplace(dkey.first, index);
115 *fixedValues = deadModesValues;
121 if (pruned.
keys().size() > 0)
result.push_back(pruned);
130 std::stringstream
ss;
131 ss <<
"`DiscreteBayesNet` of size " <<
size() << endl << endl;
133 ss << conditional->markdown(keyFormatter,
names) << endl;
141 std::stringstream
ss;
142 ss <<
"<div><p><tt>DiscreteBayesNet</tt> of size " <<
size() <<
"</p>";
144 ss << conditional->html(keyFormatter,
names) << endl;
DiscreteValues sample() const
do ancestral sampling
bool equals(const This &bn, double tol=1e-9) const
static std::stringstream ss
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
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 Mar 19 2025 03:01:36