npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datareduce

v1.0.4

Published

Largest Triangle 3 Buckets with 1D Arrays as input

Downloads

33

Readme

reducedata - a Largest Triangle Three Buckets efficient downsample algorithm

Synopsis

const datareduce = require("datareduce")

dsX = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]
dsY = [ 8, 4, 2, 4, 4, 9, 8, 8, 3, 9, 7, 2, 5, 3, 7, 3 ]
reduced_len = 5

var rdsX,rdsY
[rdsX,rdsY] = datareduce.lt3b(dsX, dsY, reduced_len)

console.log('reduced X',rdsX)
console.log('reduced Y',rdsY)

Outputs

reduced X [ 1, 3, 6, 12, 16 ]
reduced Y [ 8, 2, 9, 2, 3 ]

Install

npm install git+https://github.com/troxel/datareduce.git

or

npm install datareduce

Node package to reduce or downsample data using the Largest Triangle Three Buckets algorithm

Description

Implements a downsample technique known as Largest Triangle Three Buckets (lttb or lt3b) as defined in Sveinn Steinarsson MS thesis.

http://skemman.is/stream/get/1946/15343/37285/3/SS_MSthesis.pdf

The idea is to downsample a data set without losing the visual character of the plotted data. The technique draws on ideas in cartographic generalization or polyline simplification. This technique is often useful in client-server applications such as webserver-browser where the length of the data far exceeds the pixels available to plot. Reducing the data size significantly speeds up data transfer and rendering time.

There are other packages that do the same but expect input of the form

data = [ [1,5], [2.4], [3,7]...]

Which is not suitable for many plotting packages such as plotly or matplotlit or dygraph which use data in the form

dataX = [1,2,3...]
datay = [5,4,7...]

When converting 100000s of data points the cost is significant to convert back and forth.

The package implicitly handles the situation of the x-axis being a Date object which is common with many plotting use cases.

In the test directory there is a program that compares the performance with respect to other packages and checks against a reference to verify results are as expected

Time to reduce 70000 data points to 1000
-------------------------
d3fc-sample:      55.86ms
-------------------------
downsampler-lttb: 21.789ms
-------------------------
reducedata.lt3b:  19.792ms
-------------------------
Comparison of reduced dataset between lttb and lt3b are EQUAL :)

Results per Node.js v18.12.0 on Raspberry Pi 4.

Note: In order to run the performance and compare test script it will be required to install 'downsample-lttb' and 'd3fc-sample' ~