Example 2: Two fair coins and one counter

Example 2: Two fair coins and one counter

Example 2: CPD and conditional expectation of random variable 'Count'

Andrew D. Gordon, Thomas A. Henzinger, Aditya V. Nori, and Sriram K. Rajamani. 2014. Probabilistic programming. In Proceedings of the on Future of Software Engineering (FOSE 2014). ACM, New York, NY, USA, 167-181. DOI=10.1145/2593882.2593900 doi.acm.org/10.1145/2593882.2593900

PROB-Code for E(Count | C1=1 v C2=1)

"This program ... counts the number of coin tosses that result in the value true, and stores this count in the variable count. The semantics of the program is the expected return value, conditioned by permitted executions. Once again, since conditioning by permitted executions yields Pr(c1=false, c2=false) = 0, and Pr(c1=false, c2=true) = Pr(c1=true, c2=false) = Pr(c1=true, c2=true) = 1/3, we have that the expected return value is 0 x0 + 1/3*1 + 1/3*1 + 1/3*2 = 4/3." (Gordon et al., 2014)

CHURCH-Code for P(Count | C1=1 v C2=1) and E(Count | C1=1 v C2=1) = 4/3

The PROB-code snippet from Gordon et al. is translated by us to a functional CHURCH program to clarify its semantics. The generative model is contained in the CHURCH function "take-a-sample". The number of samples taken was set to 10000 in this run. This number can be increased to get a better precision of estimates. The sampling method used is the simple-to-understand 'rejection sampling'. The screen-shot presented was generated by using the PlaySpace environment of WebCHURCH.

Webmaster (Changed: 27 Aug 2024)  | 
Zum Seitananfang scrollen Scroll to the top of the page