JuliaCollections / JuliaCollections/DataStructures.jl
rand() for multisets
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 745
- Forks
- 261
- PR merge metrics
- No merged PRs in 30d
Description
This package does not currently define Random.rand(::Accumulator) so the default implementation for an AbstractDictionary is used, returning a random entry x=>count of the underlying dictionary. For example, rand(DataStructures.Accumulator(Dict(2=>4))) returns 2 => 4.
In my opinion, rand should return one of the values/keys with a probability proportional to its corresponding count.
If the maintainers agree, I can implement this and prepare a pull request.
Counterpoints: This only makes sense if all counts are nonnegative and finite. The implementation would either have to store the total count and update it for every modification, or recompute it every time rand is called. Either choice will be inappropriate for some applications.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Accumulator entry point and the current rand(::AbstractDictionary) behavior to understand how multisets and counts are represented. Resolve the nonnegative, finite-count and total-count questions with maintainers, then verify that rand returns keys or values with probability proportional to their counts and add focused coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100