Package com.amalgamasimulation.utils
Class DynamicHistogramDataAggregator<C,O>
java.lang.Object
com.amalgamasimulation.utils.HistogramDataAggregator<C,O>
com.amalgamasimulation.utils.DynamicHistogramDataAggregator<C,O>
- Type Parameters:
C- type of categoryO- type of objects associated with data points
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.amalgamasimulation.utils.HistogramDataAggregator
HistogramDataAggregator.HistogramDataGroup, HistogramDataAggregator.MaxArgumentDescriptor -
Field Summary
Fields inherited from class com.amalgamasimulation.utils.HistogramDataAggregator
argumentObjectsCount, argumentsSum, biggestArgumentObjects, biggestArgumentObjectsMap, biggestGroup, categories, count, createInitialZeroGroup, dataGroups, groupSize, groupSizeModifier, initialGroupLeftBound, lastBucketIncludesRightBorder, maxArgumentDescriptor, maxGroupsCount, minGroupSizeAsPowerOf10, smallestArgumentObjects, smallestArgumentObjectsMap, sum -
Constructor Summary
ConstructorsConstructorDescriptionDynamicHistogramDataAggregator(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).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).DynamicHistogramDataAggregator(List<C> categories, int maxGroupsCount) Creates a new instance of dynamic histogram data aggregator with the specified maximum number of buckets (or groups).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). -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new data point to this aggregator.protected voidaddValueInternal(double argument, C category, double value, O obj) protected voidMethods inherited from class com.amalgamasimulation.utils.HistogramDataAggregator
addDataGroup, addDataGroup, addValue, clear, getAverage, getBiggestArgumentObjects, getBiggestArgumentObjectValue, getBiggestGroup, getCategories, getCount, getDataGroup, getDataGroups, getGroupSize, getMaxArgument, getMaxGroupsCount, getMinArgument, getMinGroupSizeAsPowerOf10, getSmallestArgumentObjects, getSmallestArgumentObjectValue, getSum, onDataGroupAdd, onDataGroupsAdjust, onDataGroupsClear, recalculateBiggestGroup, setMinGroupSizeAsPowerOf10, toString, updateMaxArgumentDescriptor
-
Constructor Details
-
DynamicHistogramDataAggregator
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 elementmaxGroupsCount- 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 elementlastBucketIncludesRightBorder- flag specifying whether the last bucket includes right bordermaxGroupsCount- 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 elementmaxGroupsCount- 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 elementlastBucketIncludesRightBorder- flag specifying whether the last bucket includes right bordermaxGroupsCount- maximum number of buckets (or groups) that can be created.argumentObjectsCount- number of outlier objects to be stored
-
-
Method Details
-
addValue
Description copied from class:HistogramDataAggregatorAdds 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:
addValuein classHistogramDataAggregator<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 peoplevalue- 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
- Specified by:
addValueInternalin classHistogramDataAggregator<C,O>
-
adjustDataGroups
protected void adjustDataGroups()- Specified by:
adjustDataGroupsin classHistogramDataAggregator<C,O>
-