sim.util.media.chart
Class MinGapDataCuller

java.lang.Object
  extended by sim.util.media.chart.MinGapDataCuller
All Implemented Interfaces:
DataCuller

public class MinGapDataCuller
extends java.lang.Object
implements DataCuller

This is meant as an on-line algorithm for keeping a constant number of data points from an on-going time series. It only looks at the X values of the time series data points.

Specifically, this algorithm eliminates the point the leaves the smallest gap (i.e. has the closest neighbors). The first and last data point are never touched.

In case of ties, it chooses the first. This is meant to make the older data sparse while keeping more/most of the fresh data. Few gaps change between removes (2 old are merged, 1 new is introduced; 1. I could cache the gap sums 2. I could use a heap (although the tie breaking might be off)

For efficiency reasons, multiple points are dropped in one culling. The suggested (default) amount of points dropped in one culling is 50%.


Constructor Summary
MinGapDataCuller(int maxPointCount)
           
MinGapDataCuller(int maxPointCount, int pointCountAfterCulling)
           
 
Method Summary
 IntBag cull(double[] xValues, boolean sortedOutput)
           
 IntBag cull(double[] xValues, IntBag droppedIndices, boolean sortOutput)
           
 IntBag cull(double[] xValues, int size, IntBag droppedIndices, boolean sortOutput)
          This must keep size elements and use the droppedIndices IntBag to store the indices of the xValues.length - size elements that do NOT survive the culling.
static IntBag cullToSize(double[] xValues, int size, IntBag droppedIndices)
           
 void setMaxAndMinCounts(int maxPointCount, int pointCountAfterCulling)
           
static void sort(IntBag indices, int maxPoints)
           
 boolean tooManyPoints(int currentPointCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MinGapDataCuller

public MinGapDataCuller(int maxPointCount,
                        int pointCountAfterCulling)

MinGapDataCuller

public MinGapDataCuller(int maxPointCount)
Method Detail

setMaxAndMinCounts

public void setMaxAndMinCounts(int maxPointCount,
                               int pointCountAfterCulling)

tooManyPoints

public boolean tooManyPoints(int currentPointCount)
Specified by:
tooManyPoints in interface DataCuller

sort

public static void sort(IntBag indices,
                        int maxPoints)

cull

public IntBag cull(double[] xValues,
                   boolean sortedOutput)
Specified by:
cull in interface DataCuller

cull

public IntBag cull(double[] xValues,
                   IntBag droppedIndices,
                   boolean sortOutput)
Specified by:
cull in interface DataCuller

cull

public IntBag cull(double[] xValues,
                   int size,
                   IntBag droppedIndices,
                   boolean sortOutput)
Description copied from interface: DataCuller
This must keep size elements and use the droppedIndices IntBag to store the indices of the xValues.length - size elements that do NOT survive the culling. The implementators can expect the xValues to be sorted! The implementators must be prepared to sort output bag if so requested.

Specified by:
cull in interface DataCuller

cullToSize

public static IntBag cullToSize(double[] xValues,
                                int size,
                                IntBag droppedIndices)