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

added a uniform distribution over a collection of objects #19

Merged
merged 5 commits into from
Jun 6, 2019

Conversation

zsunberg
Copy link
Member

@zsunberg zsunberg commented Jun 3, 2019

One question is naming. This clashes with Distributions.Uniform. Another option would be UniformCat. I think Uniform is better, but could be persuaded otherwise.

Copy link
Member

@rejuvyesh rejuvyesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm misunderstanding something, but I don't think the pdf corresponds to defined rand.

function pdf(d::Uniform, s)
d._set = something(d._set, Set(d.collection))
if s in d._set
return 1/length(d.collection)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0/length(d.collection)

Uniform(c) = Uniform{typeof(c), eltype(c)}(c, nothing)
Uniform(c::Set) = Uniform{typeof(c), eltype(c)}(c, c)

rand(rng::AbstractRNG, d::Uniform) = rand(rng, d.collection)
Copy link
Member

@rejuvyesh rejuvyesh Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear about the rationale here. If you are allowing for non-sets and converting it into sets and giving them equal weights, then how can you sample uniformly from the collection which might have multiple instances of the same and therefore higher weight?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks, I need to redesign this.

@coveralls
Copy link

coveralls commented Jun 4, 2019

Pull Request Test Coverage Report for Build 87

  • 19 of 19 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.7%) to 67.194%

Totals Coverage Status
Change from base Build 81: 2.7%
Covered Lines: 170
Relevant Lines: 253

💛 - Coveralls

@zsunberg
Copy link
Member Author

zsunberg commented Jun 6, 2019

@rejuvyesh do you think it's good now?

Copy link
Member

@rejuvyesh rejuvyesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the commented stuff. Looks good to me otherwise.

# mean(d::Uniform) = mean(d.set)
# mode(d::Uniform) = mode(d.set)
#
# function weighted_iterator(d::Uniform)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah 🤦‍♂️

@zsunberg zsunberg merged commit 0527629 into master Jun 6, 2019
@zsunberg zsunberg deleted the uniform branch June 6, 2019 16:43
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.

None yet

3 participants