-
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
20170711 iriss modules #54
Conversation
src/builtin_modules.jl
Outdated
|
||
struct DiscreteUniform <: Gen.Module{Int64} end | ||
|
||
function regenerate(::DiscreteUniform, x::Int64, a::Int64, b::Int64) |
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.
Please rename a
and b
to min and max or something equivalent, if that's what they are, and provide a comment explaining whether b
is inclusive or exclusive.
test/runtests.jl
Outdated
x = 5 | ||
a = 1 | ||
b = 10 | ||
@test isapprox(regenerate(Gen.DiscreteUniform(), x, a, b), logpdf(DiscreteUniform(a, b), x)) |
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.
As you mentioned earlier, testing by just checking against the Distributions
package isn't very good. It would be better to check against a value computed some other means (either different code, or manually computed). can you instead check that the value matches the manually computed value of log(1./9.)
or log(1./10.)
(depending on whether its inclusive or exclusive, I don't know)
@marcoct updated changes. The parameters are inclusive. |
Added discrete uniform module with test. Has been tested manually and through the test script.