ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
CollapsedAggMoment.h File Reference

Rao-Blackwellised (collapsed) evaluation of a correlated COUNT / SUM and of a latent conditioned on such a count. More...

#include <optional>
#include "GenericCircuit.h"
Include dependency graph for CollapsedAggMoment.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  provsql

Functions

std::optional< double > provsql::aggCollapsedRawMoment (const GenericCircuit &gc, gate_t agg, unsigned k)
 Collapsed raw moment E[C^k] of a correlated COUNT / SUM agg, or std::nullopt when the circuit does not match the shared-latent shape.
std::optional< double > provsql::collapsedConditionalMoment (const GenericCircuit &gc, gate_t target, gate_t event, unsigned k)
 Collapsed exact posterior raw moment E[R^k | Y = C] for a latent target R conditioned (through the equality event event) on a discrete rv Y – parametrised by target – equalling a correlated COUNT C.

Detailed Description

Rao-Blackwellised (collapsed) evaluation of a correlated COUNT / SUM and of a latent conditioned on such a count.

The recurring latent-variable relational shape is an aggregate over probabilistically-selected rows whose selection events are coupled by ONE shared continuous latent. Conditional on that latent the row indicators are independent, so the aggregate's moments – and the posterior of a latent conditioned on the aggregate – collapse to a 1-D quadrature over the shared latent instead of an n^k tuple enumeration or a degenerating importance sampler. See CollapsedAggMoment.cpp for the recognised shape.

Definition in file CollapsedAggMoment.h.