Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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