hakaru-dev / hakaru

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

Erlang test4 #160

Closed sohraa3 closed 6 years ago

sohraa3 commented 6 years ago

This branch includes additions that would be used to test the fifth relationship here: https://en.wikipedia.org/wiki/Erlang_distribution#Related_distributions

The files tests/RoundTrip2/t_erlang_to_pareto.0.hk and tests/RoundTrip2/t_erlang_to_pareto.expected.hk are the test and expected respectively.

The output of this test was the following:

Failure in: 6:RoundTrip:7:0:t_erlang_to_pareto:0

haskell/Tests/TestTools.hs:130
expected:
fn n nat:
X <~ uniform(nat2real(0), nat2real(1))
return 1/ real2prob(X) ** prob2real(1/ nat2prob(n))
but got:
fn n nat:
X5 <~ uniform(+0/1, +1/1)
return real2prob(1/ X5) * nat2prob(n)

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

haskell/Tests/TestTools.hs:176
Files don't have same type (
fn n nat:
    X <~ uniform(0,1)
    return (1 / (real2prob(X) ** (1/n))) #this is our implimentatio of pareto
 :: nat -> measure(prob), 

def exponential(alpha prob):
    X <~ uniform(0,1)
    return (-1 * alpha * log(real2prob(X)))

def erlang(shape nat, scale prob) measure(prob):
    gamma(nat2prob(shape), scale)

fn n nat:
    fn lambda prob:
        U <~ exponential(lambda)
        V <~ erlang(n,lambda)
        return real2prob(U/V+1)

 :: nat -> prob -> measure(prob)