-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared tests for various distributions #35
Conversation
@@ -47,8 +47,8 @@ | |||
([] (uniform-distribution 0.0 1.0)) | |||
([lo hi] (->Uniform (rng) lo hi))) | |||
|
|||
(defn gaussian-distribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to match the other conventions / Gen.jl's convention.
Codecov Report
@@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 62.50% 66.51% +4.01%
==========================================
Files 14 16 +2
Lines 616 666 +50
Branches 21 21
==========================================
+ Hits 385 443 +58
+ Misses 210 202 -8
Partials 21 21
|
@@ -85,7 +85,7 @@ | |||
{:pre [(pos? alpha) (pos? beta)]} | |||
(if (< 0 v 1) | |||
(- (+ (* (- alpha 1) (Math/log v)) | |||
(* (- beta alpha) (Math/log (- 1 v)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops!
|
||
The implementation follows the algorithm described on the Cauchy | ||
distribution's [Wikipedia | ||
page](https://en.wikipedia.org/wiki/Cauchy_distribution#Probability_density_function_(PDF))." | ||
[scale location v] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing these to match Gen.jl's arg order.
fb8dee0
to
57aa1ca
Compare
@sritchie Tagging @Schaechtle in on this one! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks mostly good: I left minor inline comments. However, this line indicates an error due to name clashing of gen.trace
and gen/trace
. If this is fixed by a different PR, feel free to update/ignore
(checking "Delta properties" | ||
[center (gen-double -100 100) | ||
v (gen-double -100 100)] | ||
(if (= center v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused: Unless I am misreading what gen/double*
does, this will never hold. Or is there some shared random seeding that I am missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually calling
(defn gen-double
"Returns a generator that produces numerical doubles between `min` and
`max` (inclusive)."
[min max]
(gen/double*
{:min min :max max :infinite? false :NaN? false}))
and with shrinking, center
and v
will both match probably at least once on each test run (as the generator tries the min, max, 0, etc)
But let me know if I am missing something!
test/gen/distribution_test.cljc
Outdated
(is (= -1.8862943611198906 (dist/logpdf (->laplace 0 2) 1))) | ||
(is (= 4.214608098422191 (dist/logpdf (->laplace 0 0.001) 0.002))))) | ||
|
||
(defn gaussian-tests [->gaussian] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be renamed to normal
, too.
@Schaechtle yep, that was a problem for cljs, fixed in #41 . Thank you! |
d078f60
to
fe597aa
Compare
fe597aa
to
70df6e0
Compare
@zane , let me know what you think of this approach. This gives at least a baseline of tests for each of the logpdf implementations (and writing these exposed a bug I had in my beta log-likelihood!)
I'll add docs to each of the distribution namespaces before we merge.