gov.sandia.cognition.statistics.distribution
Class ScalarDataDistribution

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.collection.AbstractScalarMap<KeyType>
          extended by gov.sandia.cognition.collection.AbstractMutableDoubleMap<KeyType>
              extended by gov.sandia.cognition.statistics.AbstractDataDistribution<KeyType>
                  extended by gov.sandia.cognition.statistics.distribution.DefaultDataDistribution<Double>
                      extended by gov.sandia.cognition.statistics.distribution.ScalarDataDistribution
All Implemented Interfaces:
NumericMap<Double>, ScalarMap<Double>, ComputableDistribution<Double>, DataDistribution<Double>, DiscreteDistribution<Double>, Distribution<Double>, DistributionWithMean<Double>, EstimableDistribution<Double,DataDistribution<Double>>, UnivariateDistribution<Double>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
ScalarDataDistribution.CDF, ScalarDataDistribution.PMF

public class ScalarDataDistribution
extends DefaultDataDistribution<Double>
implements UnivariateDistribution<Double>

A Data Distribution that uses Doubles as its keys, making it a univariate distribution

Since:
3.1
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class ScalarDataDistribution.CDF
          CDF of the ScalarDataDistribution, maintains the keys/domain in sorted order (TreeMap), so it's slower than it's peers.
static class ScalarDataDistribution.Estimator
          Estimator for a ScalarDataDistribution
static class ScalarDataDistribution.PMF
          PMF of the ScalarDataDistribution
 
Nested classes/interfaces inherited from class gov.sandia.cognition.statistics.distribution.DefaultDataDistribution
DefaultDataDistribution.DefaultFactory<DataType>, DefaultDataDistribution.WeightedEstimator<KeyType>
 
Nested classes/interfaces inherited from class gov.sandia.cognition.collection.AbstractMutableDoubleMap
AbstractMutableDoubleMap.SimpleEntry<KeyType>, AbstractMutableDoubleMap.SimpleEntrySet<KeyType>, AbstractMutableDoubleMap.SimpleIterator<KeyType>
 
Nested classes/interfaces inherited from class gov.sandia.cognition.collection.AbstractScalarMap
AbstractScalarMap.MapWrapper
 
Nested classes/interfaces inherited from interface gov.sandia.cognition.collection.ScalarMap
ScalarMap.Entry<KeyType>
 
Field Summary
 
Fields inherited from class gov.sandia.cognition.statistics.distribution.DefaultDataDistribution
DEFAULT_INITIAL_CAPACITY, total
 
Fields inherited from class gov.sandia.cognition.collection.AbstractMutableDoubleMap
map
 
Constructor Summary
  ScalarDataDistribution()
          Creates a new instance of ScalarDataDistribution
  ScalarDataDistribution(Iterable<? extends Number> data)
          Creates a new instance of ScalarDataDistribution
protected ScalarDataDistribution(Map<Double,MutableDouble> map, double total)
          Creates a new instance of ScalarDataDistribution
  ScalarDataDistribution(ScalarDataDistribution other)
          Copy constructor
 
Method Summary
 ScalarDataDistribution clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 ScalarDataDistribution.CDF getCDF()
          Gets the CDF of a scalar distribution.
 ScalarDataDistribution.Estimator getEstimator()
          Gets an estimator associated with this distribution.
 Double getMaxSupport()
          Gets the minimum support (domain or input) of the distribution.
 Double getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 Double getMinSupport()
          Gets the minimum support (domain or input) of the distribution.
 ScalarDataDistribution.PMF getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 double getVariance()
          Gets the variance of the distribution.
 
Methods inherited from class gov.sandia.cognition.statistics.distribution.DefaultDataDistribution
clear, getMeanValue, getTotal, increment, set
 
Methods inherited from class gov.sandia.cognition.statistics.AbstractDataDistribution
fromInfiniteVector, getDomain, getDomainSize, getEntropy, getFraction, getLogFraction, getMaxValue, getMinValue, sample, sample, toInfiniteVector
 
Methods inherited from class gov.sandia.cognition.collection.AbstractMutableDoubleMap
asMap, compact, containsKey, entrySet, get, keySet, size
 
Methods inherited from class gov.sandia.cognition.collection.AbstractScalarMap
decrement, decrement, decrementAll, decrementAll, getMaxValueKey, getMaxValueKeys, getMinValueKey, getMinValueKeys, increment, incrementAll, incrementAll, isEmpty, setAll
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.Distribution
sample, sample
 
Methods inherited from interface gov.sandia.cognition.collection.ScalarMap
asMap, decrement, decrement, decrementAll, decrementAll, entrySet, get, increment, incrementAll, incrementAll, setAll
 
Methods inherited from interface gov.sandia.cognition.collection.NumericMap
containsKey, getMaxValueKey, getMaxValueKeys, getMinValueKey, getMinValueKeys, isEmpty, keySet, size
 

Constructor Detail

ScalarDataDistribution

public ScalarDataDistribution()
Creates a new instance of ScalarDataDistribution


ScalarDataDistribution

public ScalarDataDistribution(ScalarDataDistribution other)
Copy constructor

Parameters:
other - ScalarDataDistribution to copy

ScalarDataDistribution

public ScalarDataDistribution(Iterable<? extends Number> data)
Creates a new instance of ScalarDataDistribution

Parameters:
data - Data to create the distribution

ScalarDataDistribution

protected ScalarDataDistribution(Map<Double,MutableDouble> map,
                                 double total)
Creates a new instance of ScalarDataDistribution

Parameters:
map -
total -
Method Detail

clone

public ScalarDataDistribution clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object 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.

Specified by:
clone in interface DataDistribution<Double>
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class DefaultDataDistribution<Double>
Returns:
A clone of this object.

getProbabilityFunction

public ScalarDataDistribution.PMF getProbabilityFunction()
Description copied from interface: ComputableDistribution
Gets the distribution function associated with this Distribution, either the PDF or PMF.

Specified by:
getProbabilityFunction in interface ComputableDistribution<Double>
Specified by:
getProbabilityFunction in interface DataDistribution<Double>
Specified by:
getProbabilityFunction in interface DiscreteDistribution<Double>
Overrides:
getProbabilityFunction in class DefaultDataDistribution<Double>
Returns:
Distribution function associated with this Distribution.

getMean

public Double getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.

Specified by:
getMean in interface DistributionWithMean<Double>
Returns:
Mean of the distribution.

getEstimator

public ScalarDataDistribution.Estimator getEstimator()
Description copied from interface: EstimableDistribution
Gets an estimator associated with this distribution.

Specified by:
getEstimator in interface DataDistribution<Double>
Specified by:
getEstimator in interface EstimableDistribution<Double,DataDistribution<Double>>
Overrides:
getEstimator in class DefaultDataDistribution<Double>
Returns:
A distribution estimator associated for this distribution.

getMinSupport

public Double getMinSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMinSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getMaxSupport

public Double getMaxSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMaxSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getCDF

public ScalarDataDistribution.CDF getCDF()
Description copied from interface: UnivariateDistribution
Gets the CDF of a scalar distribution.

Specified by:
getCDF in interface UnivariateDistribution<Double>
Returns:
CDF of the scalar distribution.

getVariance

@PublicationReference(title="Algorithms for calculating variance",
                      type=WebPage,
                      year=2010,
                      author="Wikipedia",
                      url="http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance")
public double getVariance()
Description copied from interface: UnivariateDistribution
Gets the variance of the distribution. This is sometimes called the second central moment by more pedantic people, which is equivalent to the square of the standard deviation.

Specified by:
getVariance in interface UnivariateDistribution<Double>
Returns:
Variance of the distribution.