import Data.Ratio
main = do
print $ dicePosteriors
[6] [6] print $ dicePosteriors
[4, 6, 8] [6] [[6], [6,4,8,7,7,2,6], [4,8,7,7,2,6], [6,8,7,7,5,4]]
dicePosteriors suite xxs = f xxs
where
f (x:xs) = g (p x [1,1..]) xs
where
g ys [] = ys
g ys (h:t) = g (p h ys) t
f _ = []
p x priors
= map (/ n
) zs
where
ls
= map (likelihood x
) suite
likelihood x hypo
| hypo < x = 0
aW1wb3J0IERhdGEuUmF0aW8KCm1haW4gOjogSU8gKCkKbWFpbiA9IGRvCiAgcHJpbnQgJCBkaWNlUG9zdGVyaW9ycyBbNl0gWzZdCiAgcHJpbnQgJCBkaWNlUG9zdGVyaW9ycyBbNCwgNiwgOF0gWzZdCiAgbWFwTV8gKHByaW50IC4gbWFwIGZyb21SYXRpb25hbCAuIGRpY2VQb3N0ZXJpb3JzIFs0LDYsOCwxMiwyMF0pCiAgICAgICAgW1s2XSwgWzYsNCw4LDcsNywyLDZdLCBbNCw4LDcsNywyLDZdLCBbNiw4LDcsNyw1LDRdXQoKZGljZVBvc3RlcmlvcnMgOjogW0ludGVnZXJdIC0+IFtJbnRlZ2VyXSAtPiBbUmF0aW8gSW50ZWdlcl0KZGljZVBvc3RlcmlvcnMgc3VpdGUgeHhzID0gZiB4eHMKICB3aGVyZQogICAgZiAoeDp4cykgPSBnIChwIHggWzEsMS4uXSkgeHMKICAgICAgd2hlcmUKICAgICAgICBnIHlzIFtdICAgICA9IHlzCiAgICAgICAgZyB5cyAoaDp0KSA9IGcgKHAgaCB5cykgdAogICAgZiBfICAgICAgPSBbXQogICAgcCB4IHByaW9ycyA9IG1hcCAoLyBuKSB6cwogICAgICB3aGVyZQogICAgICAgIG4gID0gc3VtIHpzCiAgICAgICAgenMgPSB6aXBXaXRoICgqKSBwcmlvcnMgbHMKICAgICAgICBscyA9IG1hcCAobGlrZWxpaG9vZCB4KSBzdWl0ZQoKICAgIGxpa2VsaWhvb2QgOjogSW50ZWdlciAtPiBJbnRlZ2VyIC0+IFJhdGlvIEludGVnZXIKICAgIGxpa2VsaWhvb2QgeCBoeXBvCiAgICAgIHwgaHlwbyA8IHggID0gMAogICAgICB8IG90aGVyd2lzZSA9IDEgJSBoeXBvCg==
[1 % 1]
[0 % 1,4 % 7,3 % 7]
[0.0,0.39215686274509803,0.29411764705882354,0.19607843137254902,0.11764705882352941]
[0.0,0.0,0.9432484536722126,5.52061280612909e-2,1.5454182664965531e-3]
[0.0,0.0,0.91584527196901,8.040342579700499e-2,3.7513022339850646e-3]
[0.0,0.0,0.91584527196901,8.040342579700499e-2,3.7513022339850646e-3]