KeyType - The type of data stored at the indices, the hash keys.public abstract class AbstractDataDistribution<KeyType> extends AbstractMutableDoubleMap<KeyType> implements DataDistribution<KeyType>
DataDistribution interface.AbstractMutableDoubleMap.Entry<KeyType>, AbstractMutableDoubleMap.SimpleEntry<KeyType>, AbstractMutableDoubleMap.SimpleEntrySet<KeyType>, AbstractMutableDoubleMap.SimpleIterator<KeyType>DataDistribution.PMF<KeyType>ScalarMap.Entry<KeyType>map| Constructor and Description |
|---|
AbstractDataDistribution(java.util.Map<KeyType,MutableDouble> map)
Creates a new
AbstractDataDistribution. |
| Modifier and Type | Method and Description |
|---|---|
AbstractDataDistribution<KeyType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
fromInfiniteVector(InfiniteVector<? extends KeyType> vector)
Replaces the entries in this data distribution with the entries in the
given infinite vector.
|
java.util.Set<KeyType> |
getDomain()
Returns an object that allows an iteration through the domain
(x-axis, independent variable) of the Distribution
|
int |
getDomainSize()
Gets the size of the domain.
|
double |
getEntropy()
Computes the information-theoretic entropy of the vector in bits.
|
double |
getFraction(KeyType key)
Gets the fraction of the counts represented by the given key.
|
double |
getLogFraction(KeyType key)
Gets the natural logarithm of the fraction of the counts represented
by the given key.
|
double |
getMaxValue()
The maximum value associated with any key in the map.
|
double |
getMinValue()
The minimum value associated with any key in the map.
|
KeyType |
sample(java.util.Random random)
Draws a single random sample from the distribution.
|
java.util.ArrayList<KeyType> |
sample(java.util.Random random,
int numSamples)
Draws multiple random samples from the distribution.
|
void |
sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super KeyType> output)
Draws multiple random samples from the distribution and puts the result
into the given collection.
|
InfiniteVector<KeyType> |
toInfiniteVector()
Converts this data distribution to an infinite vector.
|
asMap, compact, entrySet, get, increment, setclear, containsKey, decrement, decrement, decrementAll, decrementAll, getMaxValueKey, getMaxValueKeys, getMinValueKey, getMinValueKeys, increment, incrementAll, incrementAll, isEmpty, keySet, setAll, setAll, sizeequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEstimator, getProbabilityFunction, getTotalasMap, decrement, decrement, decrementAll, decrementAll, entrySet, get, increment, increment, incrementAll, incrementAll, set, setAll, setAllclear, containsKey, getMaxValueKey, getMaxValueKeys, getMinValueKey, getMinValueKeys, isEmpty, keySet, sizepublic AbstractDataDistribution(java.util.Map<KeyType,MutableDouble> map)
AbstractDataDistribution.map - Map that stores the datapublic AbstractDataDistribution<KeyType> clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface DataDistribution<KeyType>clone in interface CloneableSerializableclone in class AbstractMutableDoubleMap<KeyType>public int getDomainSize()
DiscreteDistributiongetDomainSize in interface DiscreteDistribution<KeyType>public double getEntropy()
DataDistributiongetEntropy in interface DataDistribution<KeyType>public double getLogFraction(KeyType key)
DataDistributiongetLogFraction in interface DataDistribution<KeyType>key - Key to considerpublic double getFraction(KeyType key)
DataDistributiongetFraction in interface DataDistribution<KeyType>key - The key.public KeyType sample(java.util.Random random)
Distributionsample in interface Distribution<KeyType>random - Random-number generator to use in order to generate random numbers.public java.util.ArrayList<KeyType> sample(java.util.Random random, int numSamples)
Distributionsample in interface Distribution<KeyType>random - Random-number generator to use in order to generate random numbers.numSamples - Number of samples to draw from the distribution.public void sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super KeyType> output)
DistributionsampleInto in interface Distribution<KeyType>random - Random number generator to use.sampleCount - The number of samples to draw. Cannot be negative.output - The collection to add the samples into.public InfiniteVector<KeyType> toInfiniteVector()
DataDistributiontoInfiniteVector in interface DataDistribution<KeyType>InfiniteVector with values from this data
distribution.public void fromInfiniteVector(InfiniteVector<? extends KeyType> vector)
DataDistributionfromInfiniteVector in interface DataDistribution<KeyType>vector - The infinite vector to use to populate this data distribution.public double getMaxValue()
ScalarMapgetMaxValue in interface ScalarMap<KeyType>getMaxValue in class AbstractScalarMap<KeyType,MutableDouble>public double getMinValue()
ScalarMapgetMinValue in interface ScalarMap<KeyType>getMinValue in class AbstractScalarMap<KeyType,MutableDouble>public java.util.Set<KeyType> getDomain()
DiscreteDistributiongetDomain in interface DiscreteDistribution<KeyType>