Class DynamicHistogramDataAggregator<C,O>

java.lang.Object
com.amalgamasimulation.utils.HistogramDataAggregator<C,O>
com.amalgamasimulation.utils.DynamicHistogramDataAggregator<C,O>
Type Parameters:
C - type of category
O - type of objects associated with data points

public class DynamicHistogramDataAggregator<C,O> extends HistogramDataAggregator<C,O>
A HistogramDataAggregator with dynamically adjusted number of buckets and bucket size. The only parameter that is predefined for this aggregator is maximum number of buckets.

Note that this aggregator can add or restructure the buckets as the data points get added to it.

In case of exceeding the maximum allowable number of baskets, merges adjacent baskets guided by the 1-2-5-10 rule.

Buckets store each individual value, so for a large number of values it is recommended to use FixedHistogramDataAggregator instead.

Useful to store data about distributions for which there is no a priori knowledge about the possible range of arguments.

Author:
Alexey Kirillov
  • Constructor Details

    • DynamicHistogramDataAggregator

      public DynamicHistogramDataAggregator(List<C> categories, int maxGroupsCount)
      Creates a new instance of dynamic histogram data aggregator with the specified maximum number of buckets (or groups).
      Parameters:
      categories - list of categories. If no categories are needed, can contain a single element
      maxGroupsCount - maximum number of buckets (or groups) that can be created
    • DynamicHistogramDataAggregator

      public DynamicHistogramDataAggregator(List<C> categories, boolean lastBucketIncludesRightBorder, int maxGroupsCount)
      Creates a new instance of dynamic histogram data aggregator with the specified maximum number of buckets (or groups).
      Parameters:
      categories - list of categories. If no categories are needed, can contain a single element
      lastBucketIncludesRightBorder - flag specifying whether the last bucket includes right border
      maxGroupsCount - maximum number of buckets (or groups) that can be created
    • DynamicHistogramDataAggregator

      public DynamicHistogramDataAggregator(List<C> categories, int maxGroupsCount, int argumentObjectsCount)
      Creates a new instance of dynamic histogram data aggregator with the specified maximum number of buckets (or groups).
      Parameters:
      categories - list of categories. If no categories are needed, can contain a single element
      maxGroupsCount - maximum number of buckets (or groups) that can be created.
      argumentObjectsCount - number of outlier objects to be stored
    • DynamicHistogramDataAggregator

      public DynamicHistogramDataAggregator(List<C> categories, boolean lastBucketIncludesRightBorder, int maxGroupsCount, int argumentObjectsCount)
      Creates a new instance of dynamic histogram data aggregator with the specified maximum number of buckets (or groups).
      Parameters:
      categories - list of categories. If no categories are needed, can contain a single element
      lastBucketIncludesRightBorder - flag specifying whether the last bucket includes right border
      maxGroupsCount - maximum number of buckets (or groups) that can be created.
      argumentObjectsCount - number of outlier objects to be stored
  • Method Details

    • addValue

      public void addValue(double argument, C category, double value, O obj)
      Description copied from class: HistogramDataAggregator
      Adds a new data point to this aggregator. The data point is defined by argument, category and contribution.

      In the example with people's ages (see HistogramDataAggregator), the data points can be:

      • one male person of age 36: argument = 36, category = MALE, contribution = 1
      • three female persons of age 15: argument = 15, category = FEMALE, contribution = 3
      Overrides:
      addValue in class HistogramDataAggregator<C,O>
      Parameters:
      argument - determines to which bucket will the value go. In example with peoples' ages, this is the age of one or several persons.
      category - determines the category of the data point. In example with peoples' ages, this is the gender of the people
      value - determines the contribution to the bucket. In most cases, the contribution is equal to 1. In example with peoples' ages, this is number of persons.
      obj - object that is associated with the data point. In example with peoples' ages, this can be an instance of Person class. Used for outliers functionality.
    • addValueInternal

      protected void addValueInternal(double argument, C category, double value, O obj)
      Specified by:
      addValueInternal in class HistogramDataAggregator<C,O>
    • adjustDataGroups

      protected void adjustDataGroups()
      Specified by:
      adjustDataGroups in class HistogramDataAggregator<C,O>