Tutorial 1: Modeling Conditional Distribution

Build Models in PSI

PSI is a solver that does exact probabilistic inference. Here is a conditional probabilistic distribution modeled with the source language of PSI.

def main(){
    A:=flip(0.5);
    B:=flip(0.5);
    C:=flip(0.5);
    D:=A+B+C;
    observe(D>=2);
    return A;
}

Here is what the program does:

The code snippet can be found here.

Find Sensitivity

Sensitivity Definition

The result of probabilistic inference depends on the distribution parameters. In our example above, the prior flip(0.5)(Bernoulli distribution with $p = 0.5$) depends on the constant parameter 0.5. We are interested in the question: what happens to the distribution output if we perturb the parameter of the prior distibution? Notice that our example has 3 constant parameters:

A:=flip(0.5);
B:=flip(0.5);
C:=flip(0.5);

To estimate the change in the output distribution, we can add disturbance ?eps to each of our prior flip(0.5). Conceptually, we may have:

A:=flip(0.5+?eps);
B:=flip(0.5);      //Or, B:=flip(0.5+?eps2);
C:=flip(0.5);      //    C:=flip(0.5+?eps3);

PSense for Sensitivity Analysis

To automatically find the sensitivity of this probabilistic program, run the following in shell prompt:

psense -f examples/conditioning.psi

PSense changes each parameter and gets the results for different metrics:


Return to Tutorials