dice is a probabilistic programming language focused on fast exact inference
for discrete probabilistic programs.
For more information on dice, see the about page
or paper.
Below is an online dice code demo. To run the example code, press
    the "Run" button. This will print the posterior probability of the
    encryption key used by a Caesar cipher given the observed string "CCCC".
    Note that dice is still under active
    development, so there is always a chance of bugs: please help us by
    reporting them on github!
fun sendChar(key: int(2), observation: int(2)) {
   let gen = discrete(0.5, 0.25, 0.125, 0.125) in    // sample a FooLang character
   let enc = key + gen in                            // encrypt the character
   observe observation == enc
}
// sample a uniform random key: A=0, B=1, C=2, D=3
let key = discrete(0.25, 0.25, 0.25, 0.25) in
// observe the ciphertext CCCC
let tmp = sendChar(key, int(2, 2)) in
let tmp = sendChar(key, int(2, 2)) in
let tmp = sendChar(key, int(2, 2)) in
let tmp = sendChar(key, int(2, 2)) in
key
    
    
    
    
