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

Continuous random-variable helpers (distribution parsing, moments). More...

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

Go to the source code of this file.

Classes

struct  provsql::DistributionSpec
 Parsed distribution spec (family + up to two parameters). More...
struct  provsql::DistributionParam
 One parameter slot of a gate_rv, either a literal or a wire. More...
struct  provsql::DistributionTemplate
 A gate_rv distribution spec that may carry wired (token) parameters – the parse-time counterpart of DistributionSpec. More...

Namespaces

namespace  provsql

Functions

std::optional< DistributionTemplateprovsql::parse_distribution_template (const std::string &s)
 Parse the on-disk text encoding of a gate_rv distribution, keeping wired (token) parameters as wire references.
std::optional< DistributionSpecprovsql::parse_distribution_spec (const std::string &s)
 Parse the on-disk text encoding of a gate_rv distribution.
double provsql::parseDoubleStrict (const std::string &s)
 Strictly parse s as a double.
std::string provsql::double_to_text (double v)
 Format a double back into the canonical text form used by gate_value extras and gate_rv distribution parameters (the serialisation counterpart of parseDoubleStrict).
double provsql::analytical_mean (const DistributionSpec &d)
 Closed-form expectation E[X] for a basic distribution.
double provsql::analytical_variance (const DistributionSpec &d)
 Closed-form variance Var(X) for a basic distribution.
double provsql::analytical_raw_moment (const DistributionSpec &d, unsigned k)
 Closed-form raw moment \(E[X^k]\) for a basic distribution.

Detailed Description

Continuous random-variable helpers (distribution parsing, moments).

Helpers for the gate_rv leaf introduced for continuous probabilistic c-tables. A gate_rv stores its distribution name and parameters in the gate's extra byte string using a small text encoding (e.g. "normal:2.5,0.5"); these helpers parse and format that encoding, and provide closed-form moments where they exist. Arithmetic over RV expressions is built on the generic gate_arith gate (see provsql_utils.h), which is shared with non-RV scalar arithmetic.

Sampling itself lives in BooleanCircuit::monteCarlo and MonteCarloSampler; this header only exposes what is needed for parsing and analytical moment computation.

Definition in file RandomVariable.h.