ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Probability and Shapley values

Functions for computing probabilities, expected values, and game-theoretic contribution measures (Shapley/Banzhaf values) from provenance circuits. More...

Functions

DOUBLE PRECISION provsql.probability_evaluate (UUID token, TEXT method=NULL, TEXT arguments=NULL)
 Compute the probability of a provenance token.
 
DOUBLE PRECISION provsql.expected (ANYELEMENT input, UUID prov=gate_one(), TEXT method=NULL, TEXT arguments=NULL)
 Compute the expected value of an aggregate expression.
 
DOUBLE PRECISION provsql.shapley (UUID token, UUID variable, TEXT method=NULL, TEXT arguments=NULL, BOOLEAN banzhaf='f')
 Compute the Shapley value of an input variable.
 
SETOF RECORD provsql.shapley_all_vars (UUID token, TEXT method=NULL, TEXT arguments=NULL, BOOLEAN banzhaf='f', OUT UUID variable, OUT DOUBLE PRECISIONvalue)
 Compute Shapley values for all input variables at once.
 
DOUBLE PRECISION provsql.banzhaf (UUID token, UUID variable, TEXT method=NULL, TEXT arguments=NULL)
 Compute the Banzhaf power index of an input variable.
 
SETOF RECORD provsql.banzhaf_all_vars (UUID token, TEXT method=NULL, TEXT arguments=NULL, OUT UUID variable, OUT DOUBLE PRECISIONvalue)
 Compute Banzhaf power indices for all input variables at once.
 

Detailed Description

Functions for computing probabilities, expected values, and game-theoretic contribution measures (Shapley/Banzhaf values) from provenance circuits.

Function Documentation

◆ banzhaf()

DOUBLE PRECISION provsql.banzhaf ( UUID  token,
UUID  variable,
TEXT  method = NULL,
TEXT  arguments = NULL 
)

Compute the Banzhaf power index of an input variable.

Source code
provsql.sql line 1354

◆ banzhaf_all_vars()

SETOF RECORD provsql.banzhaf_all_vars ( UUID  token,
TEXT  method = NULL,
TEXT  arguments = NULL,
OUT UUID  variable,
OUT DOUBLE PRECISION  value 
)

Compute Banzhaf power indices for all input variables at once.

◆ expected()

DOUBLE PRECISION provsql.expected ( ANYELEMENT  input,
UUID  prov = gate_one(),
TEXT  method = NULL,
TEXT  arguments = NULL 
)

Compute the expected value of an aggregate expression.

Computes E[input | prov], the expected value of an aggregate result conditioned on a provenance expression. Supports SUM, MIN, and MAX aggregation functions.

Parameters
inputaggregate expression (AGG_TOKEN) to compute the expected value of
provprovenance condition (defaults to gate_one(), i.e., unconditional)
methodknowledge compilation method
argumentsadditional arguments for the method
Source code
provsql.sql line 1268

◆ probability_evaluate()

DOUBLE PRECISION provsql.probability_evaluate ( UUID  token,
TEXT  method = NULL,
TEXT  arguments = NULL 
)

Compute the probability of a provenance token.

Compiles the provenance circuit to d-DNNF and evaluates the probability. The compilation method can be selected explicitly.

Parameters
tokenprovenance token to evaluate
methodknowledge compilation method (NULL for default)
argumentsadditional arguments for the method
Source code
provsql.sql line 1249

◆ shapley()

DOUBLE PRECISION provsql.shapley ( UUID  token,
UUID  variable,
TEXT  method = NULL,
TEXT  arguments = NULL,
BOOLEAN  banzhaf = 'f' 
)

Compute the Shapley value of an input variable.

Measures the contribution of a specific input variable to the truth of a provenance expression, using game-theoretic Shapley values.

Parameters
tokenprovenance token to evaluate
variableUUID of the input variable
methodknowledge compilation method
argumentsadditional arguments for the method
banzhafif true, compute the Banzhaf value instead
Source code
provsql.sql line 1332

◆ shapley_all_vars()

SETOF RECORD provsql.shapley_all_vars ( UUID  token,
TEXT  method = NULL,
TEXT  arguments = NULL,
BOOLEAN  banzhaf = 'f',
OUT UUID  variable,
OUT DOUBLE PRECISION  value 
)

Compute Shapley values for all input variables at once.