Skip to content

Sequence sampling: seq, WeightedChoice #82

@dhardy

Description

@dhardy

This part of rand has needed work for a while, and hasn't had much love recently, excepting the excellent work on seq::sample* by @vitiral.

WeightedChoice is a distribution for sampling one item from a slice, with weights. The current API only accepts a slice (reference) and clones objects when sampling.

The seq module has functions to:

  • sample a set number of items from an iterator of unknown length, returning some of the iterated items
  • sample a set number of items from a slice, returning clones of the items
  • sample a set number of items from a slice, returning references into the original slice

Issues to solve:

  • Is this sufficiently generic/flexible? Do we cover all expected functionality?
  • Is the code succinct?
  • Is the documentation sufficient?
  • Why are WeightedChoice and seq::* in completely separate modules, the first as a distribution the second as simple functions?
  • Is there excess functionality which arguably doesn't belong in rand?

References:

I'm going to say nothing is fixed at this point. In theory it would be nice not to break the new seq code.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions