Skip to content

Instantly share code, notes, and snippets.

@arnobaer
Created June 21, 2021 10:55
Show Gist options
  • Save arnobaer/1f76a7499d736806475e0482e79a07d9 to your computer and use it in GitHub Desktop.
Save arnobaer/1f76a7499d736806475e0482e79a07d9 to your computer and use it in GitHub Desktop.
def linspace(start, stop, count):
delta = (stop - start) / max(1, count - 1)
return [start + i * delta for i in range(count)]
def sample(data, count):
n = len(data)
count = min(n, count)
return [int(round(i)) for i in linspace(0, len(data) - 1, count)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment