Skip to content

Commit de0f95b

Browse files
Added LTD API and acknowledgement to README
1 parent 91fd7db commit de0f95b

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@ There is a very minimal interactive demo app available if you want to play aroun
1616
npm install downsample
1717
```
1818

19+
## Acknowledgement
20+
21+
The implementation is based on Sveinn Steinarsson's 2013 paper _Downsampling Time Series for
22+
Visual Representation_ that can be found [here](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf).
23+
1924
## Usage
2025

21-
Two downsampling methods are currently supported, description of both can be found [here](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf):
26+
Three downsampling methods are currently supported, description of all three can be found [here](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf):
2227

2328
- Largest triangle three buckets (LTTB)
2429
- Largest triangle one bucket (LTOB)
30+
- Largest triangle dynamic (LTD)
2531

2632
Downsampling a series of data points using either of these looks like this:
2733

2834
```typescript
2935
// ES6
30-
import { LTOB, LTTB } from "downsample";
36+
import { LTD, LTOB, LTTB } from "downsample";
3137

3238
// Or old school
39+
var LTD = require("downsample").LTD;
3340
var LTOB = require("downsample").LTOB;
3441
var LTTB = require("downsample").LTTB;
3542

@@ -92,3 +99,14 @@ otherwise the results will be unpredictable.
9299
`desiredLength: number` is the length of the downsampled array.
93100

94101
This function will throw an error if the `desiredLength` is negative.
102+
103+
### downsample.LTD<T extends DataPoint>(data: T[], desiredLength: number): T[]
104+
105+
Implementation of `Largest triangle dynamic` downsampling method. Especially good for unevenly sampled data, for evenly spaced data `LTTB` should produce better results.
106+
107+
`data: DataPoint[]` is the input array. This array should be sorted by the independent variable
108+
otherwise the results will be unpredictable.
109+
110+
`desiredLength: number` is the length of the downsampled array.
111+
112+
This function will throw an error if the `desiredLength` is negative.

0 commit comments

Comments
 (0)