Class HistogramDataAggregator.HistogramDataGroup

java.lang.Object
com.amalgamasimulation.utils.HistogramDataAggregator.HistogramDataGroup
Enclosing class:
HistogramDataAggregator<C,O>

public class HistogramDataAggregator.HistogramDataGroup extends Object
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 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:
      true if the specified argument belongs to this bucket, false otherwise
    • 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

      public void addValue(double argument, C category, double contribution)
      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 people
      contribution - 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

      public double getSum(C category)
      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

      public Map<C,Double> 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

      public boolean equals(Object arg0)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object