ExLTTB v0.2.0 ExLTTB.Stream View Source
ExLTTB with lazy evalutation
Link to this section Summary
Link to this section Functions
Downsamples a samples stream using a modified version of LTTB.
The difference with the original algorithm is that since a Stream could be infinite, it doesn’t make sense to define the number of output buckets (threshold). Instead, the parameter here is the average bucket size (≈ downsample rate, see Return).
Arguments
samples_stream
: aStream
of samples. These can have any representation provided that access functions are provided (see Options). The stream is assumed to be sorted by thex
coordinate.avg_bucket_size
: the average size of a single bucket. The first (and if the Stream is not infinite, also the last) bucket has only one sample like in the original algorithmopts
: a keyword list of options.
Options
sample_to_x_fun
: a function that takes as argument a sample and returns its x coordinate. Defaults tosample[:x]
sample_to_y_fun
: a function that takes as argument a sample and returns its y coordinate. Defaults tosample[:y]
xy_to_sample_fun
: a function that takes as argumentx
andy
and returns a sample with these coordinates. Defaults to%{x: x, y: y}
Return
A downsampled Stream
. If the starting samples_stream
has a limited length L, than the length of the returned stream length is N <= 2 + ceil(L / avg_bucket_size)
.