Skip to content

Instantly share code, notes, and snippets.

@ramalho
Created May 7, 2020
Embed
What would you like to do?
from random import shuffle
from typing import Sequence, List, Any
def sample(population: Sequence, size: int) -> List:
if size < 1:
raise ValueError('size must be >= 1')
result = list(population)
shuffle(result)
return result[:size]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment