V
- The type of objectComparableDistribution
public class Distribution<V>
extends java.lang.Object
Constructor | Description |
---|---|
Distribution(CountMap<V> counts) |
Default constructor
|
Modifier and Type | Method | Description |
---|---|---|
java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,java.lang.Integer>> |
allCounts() |
Gets a stream of (object, count) pairs
|
java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,java.lang.Double>> |
allProportions() |
Get a stream of (object, proportion) pairs
|
static <W> Distribution<W> |
constantDistribution(W w) |
Creates a constant distribution - ia distribution containing a single object
|
int |
getCount(V v) |
Get the count for an object
|
double |
getProportion(V v) |
Get the proportion for n object.
|
int |
getTotal() |
Get the total count for all objects
|
V |
sample() |
Get a sample from the distribution
|
public double getProportion(V v)
v
- The objectpublic int getCount(V v)
v
- The objectpublic int getTotal()
public java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,java.lang.Integer>> allCounts()
public java.util.stream.Stream<org.apache.commons.lang3.tuple.ImmutablePair<V,java.lang.Double>> allProportions()
public V sample()
public static <W> Distribution<W> constantDistribution(W w)
W
- Type of the objectw
- The object