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

Implementation of the RV-aware Monte Carlo sampler. More...

#include "MonteCarloSampler.h"
#include "Aggregation.h"
#include "RandomVariable.h"
#include "RangeCheck.h"
#include "Circuit.h"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
#include <random>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <variant>
#include <vector>
Include dependency graph for MonteCarloSampler.cpp:

Go to the source code of this file.

Namespaces

namespace  provsql

Functions

double provsql::monteCarloRV (const GenericCircuit &gc, gate_t root, unsigned samples)
 Run Monte Carlo on a circuit that may contain gate_rv leaves.
std::vector< double > provsql::monteCarloJointDistribution (const GenericCircuit &gc, const std::vector< gate_t > &cmps, unsigned samples)
 Estimate the joint distribution of cmps via Monte Carlo.
std::vector< double > provsql::monteCarloScalarSamples (const GenericCircuit &gc, gate_t root, unsigned samples)
 Sample a scalar sub-circuit samples times and return the draws.
ConditionalScalarSamples provsql::monteCarloConditionalScalarSamples (const GenericCircuit &gc, gate_t root, gate_t event_root, unsigned samples)
 Rejection-sample root conditioned on event_root.
std::optional< std::vector< double > > provsql::try_truncated_closed_form_sample (const GenericCircuit &gc, gate_t root, gate_t event_root, unsigned n)
 Try to draw n exact samples from the conditional distribution of root given event_root via closed-form truncation, bypassing MC rejection.
bool provsql::circuitHasRV (const GenericCircuit &gc, gate_t root)
 Walk the circuit reachable from root looking for any gate_rv.

Detailed Description

Implementation of the RV-aware Monte Carlo sampler.

Definition in file MonteCarloSampler.cpp.