Skip to content
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

Merged
merged 4 commits into from
Jul 12, 2017
Merged

20170711 iriss modules #54

merged 4 commits into from
Jul 12, 2017

Conversation

mirisr
Copy link
Contributor

@mirisr mirisr commented Jul 12, 2017

Added discrete uniform module with test. Has been tested manually and through the test script.

@mirisr mirisr requested a review from marcoct July 12, 2017 14:35

struct DiscreteUniform <: Gen.Module{Int64} end

function regenerate(::DiscreteUniform, x::Int64, a::Int64, b::Int64)
Copy link
Collaborator

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))
Copy link
Collaborator

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)

@mirisr
Copy link
Contributor Author

mirisr commented Jul 12, 2017

@marcoct updated changes. The parameters are inclusive.

@marcoct marcoct merged commit 64fbc4b into master Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants