hakaru-dev / hakaru

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

Laplace to ChiSq Test #195

Open mkhattab940 opened 6 years ago

mkhattab940 commented 6 years ago

This one slipped through the cracks. Here's the failure:

### Failure in: 0:RoundTrip:0:3:t_laplace_to_stdChiSq:0
haskell/Tests/TestTools.hs:130
expected:
q <~ plate _ of 2: normal(+0/1, 1/1)
return real2prob(summate i from 0 to size(q): q[i] ^ 2)
but got:
q307 <~ normal(+0/1, 1/1)
q315 <~ normal(+0/1, 1/1)
return real2prob(q307 ^ 2 + q315 ^ 2)
Cases: 8  Tried: 7  Errors: 0  Failures: 6

### Failure in: 0:RoundTrip:0:3:t_laplace_to_stdChiSq:1
haskell/Tests/TestTools.hs:130
expected:
q <~ plate _ of 2: normal(+0/1, 1/1)
return real2prob(summate i from 0 to size(q): q[i] ^ 2)
but got:
X5 <~ gamma(1/1, 1/1)
Y3 <~ gamma(1/1, 1/1)
return abs(prob2real(X5) + prob2real(Y3) * (-1/1) + (-1/1)) * (2/1)
Cases: 8  Tried: 8  Errors: 0  Failures: 7
JacquesCarette commented 6 years ago

The expected is wrong here, at least for failure 0, the 'got' is indeed what I expected.

Failure 1 is weird - I don't understand how a plate of normals becomes two gammas when inlining.

mkhattab940 commented 6 years ago

OK, fixed the 0-test. Failure looks like this now:

### Failure in: 6:RoundTrip:0:6:t_laplace_to_stdChiSq:1
haskell/Tests/TestTools.hs:130
expected:
X1 <~ normal(+0/1, 1/1)
X2 <~ normal(+0/1, 1/1)
return real2prob(X1 ^ 2 + X2 ^ 2)
but got:
X5 <~ gamma(1/1, 1/1)
Y3 <~ gamma(1/1, 1/1)
return abs(prob2real(X5) + prob2real(Y3) * (-1/1) + (-1/1)) * (2/1)
Cases: 172  Tried: 97  Errors: 0  Failures: 11
Cases: 172  Tried: 98  Errors: 0  Failures: 11