hakaru-dev / hakaru

A probabilistic programming language
BSD 3-Clause "New" or "Revised" License
310 stars 30 forks source link

Wrong probability with just two coin flips #204

Closed ccshan closed 4 years ago

ccshan commented 4 years ago

Steps to reproduce:

$ cat demo.hk
coin1 <~ categorical([0.3, 0.7])
coin2 <~ categorical([0.3, 0.7])
if coin1 == 0:
    if coin2 == 0:
    return true
    else:
    return false
else:
    if coin2 == 1:
    return true
    else:
    return false

$ hk-maple -c Simplify demo.hk 

Expected output:

weight(29/50, return true) <|> weight(21/50, return false)

Actual output with Maple 2019 (version 1384062):

weight(79/100, return true) <|> weight(21/100, return false)

Thanks to Deena Postol for finding the bug and @samth for localizing the bug.