Class ComparableDistribution<V extends java.lang.Comparable<V>>

  • Type Parameters:
    V - The type of the comparable objects

    public class ComparableDistribution<V extends java.lang.Comparable<V>>
    extends Distribution<V>
    Represents a distribution of comparable discrete objects. Each object has a count associated with it
    • Constructor Detail

      • ComparableDistribution

        public ComparableDistribution​(CountMap<V> counts)
        Default constructor
        Parameters:
        counts - Map from object to count
    • Method Detail

      • min

        public V min()
        Gets the minimum object
        Returns:
        The minimum object
      • max

        public V max()
        Gets the maximum object
        Returns:
        The maximum object
      • limitTo

        public ComparableDistribution<V> limitTo​(V lower,
                                                 V upper)
        Create a new distribution only containing objects between lower and upper
        Parameters:
        lower - The lower object
        upper - The upper object
        Returns:
        The new distribution
      • allCounts

        public java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,​java.lang.Integer>> allCounts()
        Get a map from object to count for all objects
        Overrides:
        allCounts in class Distribution<V extends java.lang.Comparable<V>>
        Returns:
        Map of counts
      • allProportions

        public java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,​java.lang.Double>> allProportions()
        Got a map from object to proportion (of total count) for each object
        Overrides:
        allProportions in class Distribution<V extends java.lang.Comparable<V>>
        Returns:
        Map of proportions
      • countLessThan

        public int countLessThan​(V v)
        Returns the count of objects less than the given object
        Parameters:
        v - The given object
        Returns:
        Count of objects
      • proportionLessThan

        public double proportionLessThan​(V v)
        Returns the proportion of objects less than the given object
        Parameters:
        v - The given object
        Returns:
        Proportion of objects
      • countLessThanEqual

        public int countLessThanEqual​(V v)
        Returns the count of objects less than or equal the given object
        Parameters:
        v - The given object
        Returns:
        Count of objects
      • proportionLessThanEqual

        public double proportionLessThanEqual​(V v)
        Returns the proportion of objects less than or equal to the given object
        Parameters:
        v - The given object
        Returns:
        Proportion of objects
      • countGreaterThan

        public int countGreaterThan​(V v)
        Returns the count of objects greater than the given object
        Parameters:
        v - The given object
        Returns:
        Count of objects
      • proportionGreaterThan

        public double proportionGreaterThan​(V v)
        Returns the proportion of objects greater than the given object
        Parameters:
        v - The given object
        Returns:
        Proportion of objects
      • countGreaterThanEqual

        public int countGreaterThanEqual​(V v)
        Returns the count of objects greater than or equal to the given object
        Parameters:
        v - The given object
        Returns:
        Count of objects
      • proportionGreaterThanEqual

        public double proportionGreaterThanEqual​(V v)
        Returns the proportion of objects greater than or equal to the given object
        Parameters:
        v - The given object
        Returns:
        Proportion of objects
      • constantDistribution

        public static <W extends java.lang.Comparable<W>> ComparableDistribution<W> constantDistribution​(W w)
        Creates a constant distribution - ia distribution containing a single object
        Type Parameters:
        W - Type of the object
        Parameters:
        w - The object
        Returns:
        The constant distribution