ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
InformationTheory.h
Go to the documentation of this file.
1#ifndef INFORMATION_THEORY_H
2#define INFORMATION_THEORY_H
3
4/**
5 * @file InformationTheory.h
6 * @brief Information-theoretic readouts over scalar RV sub-circuits:
7 * entropy, Kullback-Leibler divergence, mutual information.
8 *
9 * The exact paths resolve a gate to a closed *density view* — a bare
10 * @c gate_rv (its family @c pdf over the integration range), a
11 * @c gate_value / categorical mixture (a finite pmf), or a Bernoulli
12 * mixture tree over independent such arms (e.g. the @c gmm
13 * constructor's cascade) — and evaluate the defining integral / sum
14 * directly. Entropy of a discrete view is Shannon entropy; of a
15 * continuous view, differential entropy (both in nats). Shapes with
16 * no density view fall back to Monte Carlo plug-in estimators at the
17 * @c provsql.rv_mc_samples budget (a histogram density for entropy, a
18 * 2-D histogram over coupled joint draws for mutual information;
19 * KL has no density-free estimator and raises instead).
20 */
21
22#include <optional>
23
24#include "GenericCircuit.h"
25
26namespace provsql {
27
28/** @brief Entropy of @p root in nats: Shannon for a discrete view,
29 * differential for a continuous one. With @p event, the entropy of
30 * the conditional distribution (MC plug-in estimate). */
31double computeEntropy(const GenericCircuit &gc, gate_t root,
32 std::optional<gate_t> event);
33
34/** @brief Kullback-Leibler divergence KL(P || Q) in nats. @c Infinity
35 * when P is not absolutely continuous w.r.t. Q (mismatched kinds, an
36 * atom / region of P outside Q's support). Both roots must resolve
37 * to density views; raises otherwise. */
38double computeKL(const GenericCircuit &gc, gate_t p_root, gate_t q_root);
39
40/** @brief Mutual information I(X; Y) in nats: exactly @c 0 for
41 * structurally independent roots, @c H(X) / @c Infinity for identical
42 * discrete / continuous roots, and the 2-D histogram plug-in estimate
43 * over coupled joint draws otherwise. */
44double computeMutualInformation(const GenericCircuit &gc, gate_t x_root,
45 gate_t y_root);
46
47} // namespace provsql
48
49#endif /* INFORMATION_THEORY_H */
gate_t
Strongly-typed gate identifier.
Definition Circuit.h:49
Semiring-agnostic in-memory provenance circuit.
double computeKL(const GenericCircuit &gc, gate_t p_root, gate_t q_root)
Kullback-Leibler divergence KL(P || Q) in nats.
double computeEntropy(const GenericCircuit &gc, gate_t root, std::optional< gate_t > event)
Entropy of root in nats: Shannon for a discrete view, differential for a continuous one.
double computeMutualInformation(const GenericCircuit &gc, gate_t x_root, gate_t y_root)
Mutual information I(X; Y) in nats: exactly 0 for structurally independent roots, H(X) / Infinity for...