Package Utils.Distribution
Class ComparableDistribution<V extends java.lang.Comparable<V>>
- java.lang.Object
-
- Utils.Distribution.Distribution<V>
-
- Utils.Distribution.ComparableDistribution<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 Summary
Constructors Constructor Description ComparableDistribution(CountMap<V> counts)
Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,java.lang.Integer>>
allCounts()
Get a map from object to count for all objectsjava.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 objectstatic <W extends java.lang.Comparable<W>>
ComparableDistribution<W>constantDistribution(W w)
Creates a constant distribution - ia distribution containing a single objectint
countGreaterThan(V v)
Returns the count of objects greater than the given objectint
countGreaterThanEqual(V v)
Returns the count of objects greater than or equal to the given objectint
countLessThan(V v)
Returns the count of objects less than the given objectint
countLessThanEqual(V v)
Returns the count of objects less than or equal the given objectComparableDistribution<V>
limitTo(V lower, V upper)
Create a new distribution only containing objects between lower and upperV
max()
Gets the maximum objectV
min()
Gets the minimum objectdouble
proportionGreaterThan(V v)
Returns the proportion of objects greater than the given objectdouble
proportionGreaterThanEqual(V v)
Returns the proportion of objects greater than or equal to the given objectdouble
proportionLessThan(V v)
Returns the proportion of objects less than the given objectdouble
proportionLessThanEqual(V v)
Returns the proportion of objects less than or equal to the given object-
Methods inherited from class Utils.Distribution.Distribution
constantDistribution, getCount, getProportion, getTotal, sample
-
-
-
-
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 objectupper
- 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 classDistribution<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 classDistribution<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
-
-