Package com.amalgamasimulation.utils
Class HistogramDataAggregator.HistogramDataGroup
java.lang.Object
com.amalgamasimulation.utils.HistogramDataAggregator.HistogramDataGroup
- Enclosing class:
HistogramDataAggregator<C,O>
Class representing a bucket of a distribution stored inside a
HistogramDataAggregator. Keeps track of sum and quantity of data
points falling in argument interval corresponding to the bucket.
Is fully controlled by the HistogramDataAggregator that it belongs to
and thus should not be mutated by the API user.
- Author:
- Aleksey Kirillov
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new data point to this bucket.booleancontainsArgument(double argument) Checks whether the specified argument belongs to this bucket.protected voiddumpMaxArgumentDescriptor(HistogramDataAggregator<C, O>.MaxArgumentDescriptor maxArgumentDescriptor) booleandoublegetCount()Returns the total number of data points in this bucket.doubleReturns the right bound of this bucket.doubleReturns the left bound of this bucket.doublegetSum()Returns the sum of values of data points of all categories.doubleReturns the total contribution (i.e., the sum of values) of data points of the specified category.Returns a mapping from categories to total contributions, i.e.toString()
-
Method Details
-
dumpMaxArgumentDescriptor
protected void dumpMaxArgumentDescriptor(HistogramDataAggregator<C, O>.MaxArgumentDescriptor maxArgumentDescriptor) -
containsArgument
public boolean containsArgument(double argument) Checks whether the specified argument belongs to this bucket. Note that this bucket contains all arguments in the interval [getMinArgument(),getMaxArgument()).- Parameters:
argument- specified argument- Returns:
trueif the specified argument belongs to this bucket,falseotherwise
-
getMinArgument
public double getMinArgument()Returns the left bound of this bucket.- Returns:
- left bound of this bucket
-
getMaxArgument
public double getMaxArgument()Returns the right bound of this bucket.- Returns:
- right bound of this bucket
-
addValue
Adds a new data point to this bucket. 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
- Parameters:
argument- argument. 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 peoplecontribution- 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.
-
getCount
public double getCount()Returns the total number of data points in this bucket.- Returns:
- total number of data points in this bucket
-
getSum
Returns the total contribution (i.e., the sum of values) of data points of the specified category.- Parameters:
category- specified category- Returns:
- total contribution of data points of the specified category
-
getSummMap
Returns a mapping from categories to total contributions, i.e. sums of all values for the respective category.- Returns:
- mapping from categories to total contributions
-
getSum
public double getSum()Returns the sum of values of data points of all categories.- Returns:
- total contribution of data points of the specified category
-
equals
-
toString
-