Sampling strategy for snapshot-side TimeSeries.sample /
PartitionedTimeSeries.sample. Includes both stride and reservoir;
batch is single-pass over a known-N events array, so reservoir's
Algorithm R has no eviction-protocol concerns and ships in v0.17.0.
Stride ({ stride: N }): keeps every Nth event, uniform-over-
time. Cheap, deterministic. Default for "I want my windowed stats
to use a thinned stream."
Reservoir ({ reservoir: { size: K } }): K-of-N random via
Algorithm R. Single-pass; sorts the result by key to preserve
TimeSeries's chronological invariant. Default for visualization
(series.sample({reservoir:{size:500}}).toRows() gives uncorrelated
points — no aggregate(seq, ...) grid collapse) and population-
level summaries.
When to use which:
Use case
Stride
Reservoir
Sliding-window stats (rolling avg / percentiles)
✅ default
n/a
Population summary over the snapshot
⚠️ regular-spacing
✅ default
Visualization (scatter plot, sparkline)
⚠️ regular-spacing
✅ default
Top-K / unique reducers
❌ misses singletons
⚠️ also misses
Reducer outputs ('count', 'sum', 'samples', topN)
downstream of sample reflect the sampled stream, not the source.
Multiply by stride / by N/K to estimate true counts.
Sampling strategy for snapshot-side
TimeSeries.sample/PartitionedTimeSeries.sample. Includes both stride and reservoir; batch is single-pass over a known-N events array, so reservoir's Algorithm R has no eviction-protocol concerns and ships in v0.17.0.Stride (
{ stride: N }): keeps every Nth event, uniform-over- time. Cheap, deterministic. Default for "I want my windowed stats to use a thinned stream."Reservoir (
{ reservoir: { size: K } }): K-of-N random via Algorithm R. Single-pass; sorts the result by key to preserveTimeSeries's chronological invariant. Default for visualization (series.sample({reservoir:{size:500}}).toRows()gives uncorrelated points — noaggregate(seq, ...)grid collapse) and population- level summaries.When to use which:
Reducer outputs (
'count','sum','samples',topN) downstream ofsamplereflect the sampled stream, not the source. Multiply by stride / byN/Kto estimate true counts.