Skip to content

Instantly share code, notes, and snippets.

@rbino
Created March 23, 2018 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbino/6d56a1a0399ba03941b33c7f797b3036 to your computer and use it in GitHub Desktop.
Save rbino/6d56a1a0399ba03941b33c7f797b3036 to your computer and use it in GitHub Desktop.
ExLTTB.Stream example
input_stream =
Stream.iterate(%{x: 0, y: :random.uniform() * 100}, fn %{x: x} ->
%{x: x + 1, y: :random.uniform() * 100}
end)
# Take 20 samples output samples after downsampling by 2.3
# The 20 output samples will correspond to ~ 20 * 2.3 input samples
output_samples =
ExLTTB.Stream.downsample(input_stream, 2.3)
|> Enum.take(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment