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

Sample *without* replacement? #5

Open
tabatkins opened this issue Apr 23, 2024 · 0 comments
Open

Sample *without* replacement? #5

tabatkins opened this issue Apr 23, 2024 · 0 comments

Comments

@tabatkins
Copy link
Collaborator

Python offers both sampling with replacement (every value is independent) and sampling without replacement (each value can't occur again in the same call). I think these are pretty useful; there's a lot of examples where you need to sample without replacement, like drawing card hands, and writing such a sampling function can be a bit annoying.

Do we want to add such a function? Python's method is

random.sample(items, numSamples, counts=None)

where counts is an optional array, of the same length as items, that lets you manually specify how many times each item should be considered to be in the collection. (So you don't have to manually repeat the item the specified number of times.)

I suspect we'd want to take the counts value as an options bag, like Random.sample(items, num, {counts}).

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

No branches or pull requests

1 participant