hakaru-dev / hakaru

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

Cauchy test 4 #191

Open staplejw opened 6 years ago

staplejw commented 6 years ago

Failure in: 6:RoundTrip:7:0:t_cauchy_to_students_t:0

haskell/Tests/TestTools.hs:130 expected: chiSqiid = fn n nat: fn mean real: fn stdev prob: q <~ plate of n: normal(mean, stdev) return summate i from 0 to size(q): ((q[i] - mean) * prob2real(1/ stdev)) ^ 2 standardChiSq = fn n nat: chiSq_iid(n, nat2real(0), nat2prob(1)) standardChi = fn n nat: q <~ standardChiSq(n) return sqrt(real2prob(q)) nonCentralT = fn n nat: fn delta prob: U <~ normal(nat2real(0), nat2prob(1)) X <~ standardChi(n) return (U + prob2real(delta))

Failure in: 6:RoundTrip:7:0:t_cauchy_to_students_t:1

haskell/Tests/TestTools.hs:130 expected: chiSqiid = fn n nat: fn mean real: fn stdev prob: q <~ plate of n: normal(mean, stdev) return summate i from 0 to size(q): ((q[i] - mean) * prob2real(1/ stdev)) ^ 2 standardChiSq = fn n nat: chiSq_iid(n, nat2real(0), nat2prob(1)) standardChi = fn n nat: q <~ standardChiSq(n) return sqrt(real2prob(q)) nonCentralT = fn n nat: fn delta prob: U <~ normal(nat2real(0), nat2prob(1)) X <~ standardChi(n) return (U + prob2real(delta))

mkhattab940 commented 6 years ago

Done in-lining. Test now fails like this:

### Failure in: 6:RoundTrip:0:2:t_cauchy_to_students_t:1
haskell/Tests/TestTools.hs:130
expected:
U <~ normal(+0/1, 1/1)
X <~ normal(+0/1, 1/1)
return U * prob2real(1/ abs(X))
but got:
p5 <~ normal(+0/1, 1/1)
p3 <~ normal(+0/1, 1/1)
return p5 / p3
Cases: 164  Tried: 89  Errors: 0  Failures: 5
Cases: 164  Tried: 90  Errors: 0  Failures: 5
JacquesCarette commented 6 years ago

Hmmm, why does your expected have an 'abs' but the result doesn't? That is very puzzling.

JacquesCarette commented 6 years ago

I've looked at the question you ask (i.e. what the test is) -- it is your 'expected' which is wrong. What you 'got' is correct.

mkhattab940 commented 6 years ago

Ok fixed