ggalmazor / lt_downsampling_java8

Largest Triangle Three Buckets downsampling algorithm implementation for Java8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Largest-Triangle downsampling algorithm implementations for Java8


Buy Me A Coffee

These implementations are based on the paper "Downsampling Time Series for Visual Representation" by Sveinn Steinarsson from the Faculty of Industrial Engineering, Mechanical Engineering and Computer Science University of Iceland (2013). You can read the paper here

The goal of Largest-Triangle downsampling algorithms for data visualization is to reduce the number of points in a number series without losing important visual features of the resulting graph. It is important to be aware that these algorithms are not numerically correct.

See how this algorithm compares to other algorithms designed to keep local extrema in the input series at ggalmazor.com/blog/evaluating_downsampling_algorithms.html

Download

Latest version: 0.1.0

You can add this library into your Maven/Gradle/SBT/Leiningen project using a couple of source repositories

JitPack.io

Please follow the instructions at the JitPack.io page for this project. Gradle example:

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}

dependencies {
  implementation 'com.github.ggalmazor:lt_downsampling_java8:0.1.0'
}

GithHub Package Repository

⚠️ Warning: Access to Maven repos hosted by GitHub requires authentication. More information at https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry.

Please follow the instructions at the GitHub Package Repository for this project. Gradle example:

repositories {
    maven {
        url = uri("https://maven.pkg.github.com/ggalmazor/lt_downsampling_java")
        credentials {
            username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
            password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
        }
   }
}

dependencies {
  implementation 'com.github.ggalmazor:lt_downsampling_java8:0.1.0'
}

Largest-Triangle Three-Buckets

This version of the algorithm groups numbers in same sized buckets and then selects from each bucket the point that produces the largest area with points on neighbour buckets.

You can produce a downsampled version of an input series with:

List<Point> input = Arrays.asList(...);
int numberOfBuckets = 200;

List<Point> output = LTThreeBuckets.ofSorted(input, numberOfBuckets);

First and last points of the original series are always in the output. Then, the rest are grouped into the defined amount of buckets and the algorithm chooses the best point from each bucket, resulting in a list of 202 elements.

Notes on Point types

  • This library requires to provide lists of instances of the Point supertype.
  • It also provides and uses internally the DoublePoint subtype, which can also be used to feed data to the library.
  • However, users are free to create implementations of Point that best fit their Domain.

Largest-Triangle Dynamic

Not yet implemented

Example

This is how a raw timeseries with ~5000 data points and downsampled versions (2000, 500, and 250 buckets) look like (graphed by AirTable) image image image image

These are closeups for 250, 500, 1000, and 2000 buckets with raw data in the back: image image image image

Other java implementations you might want to check

About

Largest Triangle Three Buckets downsampling algorithm implementation for Java8

License:Other


Languages

Language:Java 100.0%