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

Implement random sample with replacement #173

Closed
jdittrich opened this issue Feb 16, 2017 · 1 comment
Closed

Implement random sample with replacement #173

jdittrich opened this issue Feb 16, 2017 · 1 comment

Comments

@jdittrich
Copy link

Story: As a user I would like to draw random samples with replacement to generate bootstraps (or, in general, generate a series of independent random values from an array).

Suggested implementation: most natural would be adding an optional parameter to shuffle that allows to specify if the sample should be created with or without replacement.

@tmcw
Copy link
Member

tmcw commented Feb 16, 2017

Good idea! Random sampling with replacement, as far as I can tell, can be implemented as something like

for sample count ->
  pick random integer from 0 to size of dataset
  add dataset[random integer] to sample

Which is faster than an equivalent shuffle, since shuffles that sample the entire dataset would need to be O(n) wrt the dataset, whereas this can be O(n) or whatever, for the size of the sample.

tmcw added a commit that referenced this issue Feb 17, 2017
Implements simple sampling with replacement, which, in contrast to the existing sample method,

allows an item to be chosen more than once.

Fixes #173
tmcw added a commit that referenced this issue Feb 17, 2017
Implements simple sampling with replacement, which, in contrast to the existing sample method,

allows an item to be chosen more than once.

Fixes #173
tmcw added a commit that referenced this issue Feb 17, 2017
Implements simple sampling with replacement, which, in contrast to the existing sample method,

allows an item to be chosen more than once.

Fixes #173
tmcw added a commit that referenced this issue Feb 17, 2017
Implements simple sampling with replacement, which, in contrast to the existing sample method,

allows an item to be chosen more than once.

Fixes #173
@tmcw tmcw closed this as completed in #174 Feb 17, 2017
tmcw added a commit that referenced this issue Feb 17, 2017
Implements simple sampling with replacement, which, in contrast to the existing sample method,

allows an item to be chosen more than once.

Fixes #173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants