From 3a234bfecf800bf35b0a2a0e4382fba78aee5f4c Mon Sep 17 00:00:00 2001 From: Justin Staples Date: Mon, 9 Apr 2018 09:48:36 -0400 Subject: [PATCH 1/3] adding test for cauchy reciprocal transformation --- haskell/Tests/RoundTrip.hs | 6 ++++++ .../t_cauchy_reciprocal_transformation.0.hk | 15 +++++++++++++++ ...t_cauchy_reciprocal_transformation.expected.hk | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/RoundTrip2/t_cauchy_reciprocal_transformation.0.hk create mode 100644 tests/RoundTrip2/t_cauchy_reciprocal_transformation.expected.hk diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index 810746e3..1c3b1dd8 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -211,6 +211,11 @@ testStdChiSqRelations = test [ "t_rayleigh_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_stdChiSq.0.hk" "tests/RoundTrip2/t_rayleigh_to_stdChiSq.expected.hk" ] +testCauchyRelations :: Test +testCauchyRelations = test [ + "t_cauchy_reciprocal_transformation" ~: testConcreteFiles "tests/RoundTrip2/t_cauchy_reciprocal_transformation.0.hk" "tests/RoundTrip2/t_cauchy_reciprocal_transformation.expected.hk" + ] + testOther :: Test testOther = test [ "t82" ~: testConcreteFiles "tests/RoundTrip/t82.0.hk" "tests/RoundTrip/t82.expected.hk", @@ -253,6 +258,7 @@ allTests = test , testMeasureNat , testMeasureInt , testStdChiSqRelations + , testCauchyRelations , testOther ] diff --git a/tests/RoundTrip2/t_cauchy_reciprocal_transformation.0.hk b/tests/RoundTrip2/t_cauchy_reciprocal_transformation.0.hk new file mode 100644 index 00000000..a262c13c --- /dev/null +++ b/tests/RoundTrip2/t_cauchy_reciprocal_transformation.0.hk @@ -0,0 +1,15 @@ +def stdNormal(): + p <~ normal(0, 1) + return p + +def stdCauchy(): + X1 <~ stdNormal() + X2 <~ stdNormal() + return X1/X2 + +def cauchy(a real, alpha prob): + X <~ stdCauchy() + return a + alpha*X + +X <~ cauchy(0, 2) +return 1 / X \ No newline at end of file diff --git a/tests/RoundTrip2/t_cauchy_reciprocal_transformation.expected.hk b/tests/RoundTrip2/t_cauchy_reciprocal_transformation.expected.hk new file mode 100644 index 00000000..fa5593ea --- /dev/null +++ b/tests/RoundTrip2/t_cauchy_reciprocal_transformation.expected.hk @@ -0,0 +1,15 @@ +def stdNormal(): + p <~ normal(0, 1) + return p + +def stdCauchy(): + X1 <~ stdNormal() + X2 <~ stdNormal() + return X1/X2 + +def cauchy(a real, alpha prob): + X <~ stdCauchy() + return a + alpha*X + +X <~ cauchy(0, 1/2) +return X \ No newline at end of file From fcba2728261ffd21fd791c6cf3489033dcc8b803 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Tue, 24 Apr 2018 01:29:41 -0400 Subject: [PATCH 2/3] inlining --- tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk b/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk index efb1d8db..032e7a0b 100644 --- a/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk +++ b/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk @@ -1,4 +1,4 @@ #cauchy(0,1/2) X1 <~ normal(+0/1, 1/1) X2 <~ normal(+0/1, 1/1) -return X1/X2*1/2 \ No newline at end of file +return X1/X2*(+1/2) \ No newline at end of file From f491a8005a006969ac607ec81569f105b4547575 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Tue, 24 Apr 2018 13:56:03 -0400 Subject: [PATCH 3/3] Fix --- tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk b/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk index 032e7a0b..645ad7a3 100644 --- a/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk +++ b/tests/RoundTrip/t_cauchy_reciprocal_transformation.expected.hk @@ -1,4 +1,4 @@ #cauchy(0,1/2) X1 <~ normal(+0/1, 1/1) X2 <~ normal(+0/1, 1/1) -return X1/X2*(+1/2) \ No newline at end of file +return 1/X2*X1*(+1/2) \ No newline at end of file