![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
SQL function provsql.rv_analytical_curves(token, samples, prov). More...
#include "postgres.h"#include "fmgr.h"#include "utils/jsonb.h"#include "utils/fmgrprotos.h"#include "utils/uuid.h"#include "provsql_utils.h"#include "provsql_error.h"#include "AnalyticEvaluator.h"#include "CircuitFromMMap.h"#include "Expectation.h"#include "GenericCircuit.h"#include "HybridEvaluator.h"#include "RandomVariable.h"#include "RangeCheck.h"#include "provsql_utils_cpp.h"#include <algorithm>#include <cmath>#include <iomanip>#include <limits>#include <optional>#include <sstream>#include <tuple>#include <type_traits>#include <utility>#include <variant>#include <vector>
Go to the source code of this file.
Namespaces | |
| namespace | provsql |
Functions | |
| std::optional< std::vector< std::tuple< double, double, double > > > | provsql::analyticalHistogram (const ClosedFormShape &shape, int bins) |
Exact histogram (bin_lo, bin_hi, probability mass) of a closed-form shape, in bins equal-width bins over its natural range. | |
| Datum | rv_analytical_curves (PG_FUNCTION_ARGS) |
SQL function provsql.rv_analytical_curves(token, samples, prov).
Returns a JSON object with closed-form curves for the (possibly conditional) distribution rooted at token, or NULL when no closed form applies. The payload has up to three fields:
pdf – samples evenly-spaced {x, p} points covering the continuous part of the distribution. Absent for pure-discrete shapes (Dirac / categorical).cdf – same x grid as pdf, with cumulative probability.stems – point masses {x, p} produced by Dirac (gate_value wrapped as an as_random) or categorical roots, or by Dirac/ categorical arms inside a Bernoulli mixture. Weights propagate through nested mixtures (each ancestor's p / 1-p applies).Used by ProvSQL Studio's Distribution profile panel to overlay analytical curves and point-mass discs on the empirical histogram drawn from rv_histogram.
Supported shapes:
gate_rv root (Normal / Uniform / Exponential / Erlang with integer shape), optionally truncated by an AND-conjunct event extracted via collectRvConstraints;gate_value with finite extra, surfaced by provsql.as_random);gate_mixture (one {key, mul_1..n});gate_mixture ([p_token, x, y]) over any two recursively-matched shapes; p_token must be a bare gate_input (compound Boolean p bails).Truncation is honoured only on the bare-RV path; mixtures / categoricals / Diracs are matched only with a trivial event.
Definition in file RvAnalyticalCurves.cpp.
| Datum rv_analytical_curves | ( | PG_FUNCTION_ARGS | ) |