Downsample Oxide

Largest Triangle Three Buckets implementation based off https://github.com/jeromefroe/lttb-rs

docs.rs License crates.io

Documentation


From Jerome's Readme:

An implementation of the largest triangle three buckets (lttb) algorithm for time series downsampling as described in Downsampling Time Series for Visual Representation. This is a Rust port of the original Javascript implementation.

This implementation is heavily based and inspired from his original. Some QOL updates and datatype differences, such as using rust_decimal and offering output types to work generically or with chrono or time (both behind features).


Example

``` rust use downsample_oxide::; use chrono::;

fn firstdayofmonth(monthnum: u32) -> DateTime { NaiveDate::fromymdopt(2022, monthnum, 1) .unwrap() .andtime(NaiveTime::default()) .andlocaltimezone(Utc) .unwrap() }

fn main() { let dps = Vec::from([ DataPoint::new(firstdayofmonth(1), Decimal::from(10)), DataPoint::new(firstdayofmonth(2), Decimal::from(12)), DataPoint::new(firstdayofmonth(3), Decimal::from(8)), DataPoint::new(firstdayofmonth(4), Decimal::from(10)), DataPoint::new(firstdayof_month(5), Decimal::from(12)), ]);

let output = dps.downsample(3);

} ```