com.aliasi.stats
Class MultivariateConstant

java.lang.Object
  extended by com.aliasi.stats.AbstractDiscreteDistribution
      extended by com.aliasi.stats.MultivariateDistribution
          extended by com.aliasi.stats.MultivariateConstant
All Implemented Interfaces:
DiscreteDistribution

public class MultivariateConstant
extends MultivariateDistribution

A MultivariateConstant provides a multinomial distribution with constant probabilities and labels. A range of constructors allow a constant multivariate to be constructed from integer counts, floating point probability ratios, with an optional set of labels.

Since:
LingPipe2.0
Version:
3.8
Author:
Bob Carpenter

Constructor Summary
MultivariateConstant(double[] probabilityRatios)
          Construct a constant multinomial distribution with probabilities proportional to the specified ratios.
MultivariateConstant(double[] probabilityRatios, String[] labels)
          Construct a constant multinomial distribution with the specified labels and probabilities proportional to the specified counts.
MultivariateConstant(int numOutcomes)
          Construct a uniform constant multinomial distribution with the specified number of outcomes.
MultivariateConstant(long[] counts)
          Construct a constant multinomial distribution with probabilities proportional to the specified counts.
MultivariateConstant(long[] counts, String[] labels)
          Construct a constant multinomial distribution with the specified labels and probabilities proportional to the specified counts.
MultivariateConstant(String[] labels)
          Construct a uniform constant multinomial distribution with the specified labels.
 
Method Summary
 String label(long outcome)
          Return the label for the specified outcome.
 int numDimensions()
          Returns the number of dimensions of this multivariate distribution.
 long outcome(String outcomeLabel)
          Return the outcome for the specified label.
 double probability(long outcome)
          Return the probability of the specified outcome in this multivariate distribution.
 
Methods inherited from class com.aliasi.stats.MultivariateDistribution
log2Probability, maxOutcome, minOutcome, probability
 
Methods inherited from class com.aliasi.stats.AbstractDiscreteDistribution
cumulativeProbability, cumulativeProbabilityGreater, cumulativeProbabilityLess, entropy, log2Probability, mean, variance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultivariateConstant

public MultivariateConstant(int numOutcomes)
Construct a uniform constant multinomial distribution with the specified number of outcomes. The outcomes will be labeled as defined in MultivariateDistribution.

Parameters:
numOutcomes - Number of outcomes.
Throws:
IllegalArgumentException - If the number of outcomes is less than one.

MultivariateConstant

public MultivariateConstant(long[] counts)
Construct a constant multinomial distribution with probabilities proportional to the specified counts. The outcomes will be labeled as defined in MultivariateDistribution.

Parameters:
counts - Counts for each outcome.
Throws:
IllegalArgumentException - If any of the counts are less than zero.

MultivariateConstant

public MultivariateConstant(double[] probabilityRatios)
Construct a constant multinomial distribution with probabilities proportional to the specified ratios. The outcomes will be labeled as defined in MultivariateDistribution.

Parameters:
probabilityRatios - Probability ratios of outcomes.
Throws:
IllegalArgumentException - If any of the ratios are less than zero.

MultivariateConstant

public MultivariateConstant(String[] labels)
Construct a uniform constant multinomial distribution with the specified labels. Indices are asisgned to labels in order, and the labels must not be duplicated.

Parameters:
labels - Labels of outcomes in order of their indices.
Throws:
IllegalArgumentException - If any of the labels are duplicated.

MultivariateConstant

public MultivariateConstant(long[] counts,
                            String[] labels)
Construct a constant multinomial distribution with the specified labels and probabilities proportional to the specified counts. All counts must be non-negative and there must be the same number of labels as counts with no ducplicate labels.

Parameters:
counts - Counts for outcomes.
labels - Labels of outcomes.
Throws:
IllegalArgumentException - If any count is negative, if there are not the same number of counts and labels, or if there are duplicate labels.

MultivariateConstant

public MultivariateConstant(double[] probabilityRatios,
                            String[] labels)
Construct a constant multinomial distribution with the specified labels and probabilities proportional to the specified counts. All counts must be non-negative and there.

Parameters:
probabilityRatios - Counts for outcomes.
labels - Labels of outcomes.
Throws:
IllegalArgumentException - If any count is negative or if there are not the same number of counts and labels.
Method Detail

numDimensions

public int numDimensions()
Description copied from class: MultivariateDistribution
Returns the number of dimensions of this multivariate distribution. Note that this must be a positive number.

Specified by:
numDimensions in class MultivariateDistribution
Returns:
The number of dimensions for this distribution.

outcome

public long outcome(String outcomeLabel)
Description copied from class: MultivariateDistribution
Return the outcome for the specified label. The default implementation is to return the result of applying the method Long.parseLong(String) to the specified label. If the label is not a number, -1 is returned.

Overrides:
outcome in class MultivariateDistribution
Parameters:
outcomeLabel - Label whose outcome is returned.
Returns:
The outcome for the specified label.

label

public String label(long outcome)
Description copied from class: MultivariateDistribution
Return the label for the specified outcome. The default implementation in this class is to return the result of Long.toString(long) applied to the outcome.

Overrides:
label in class MultivariateDistribution
Parameters:
outcome - Outcome whose label is returned.
Returns:
The label for the specified outcome.

probability

public double probability(long outcome)
Description copied from class: MultivariateDistribution
Return the probability of the specified outcome in this multivariate distribution.

Specified by:
probability in interface DiscreteDistribution
Specified by:
probability in class MultivariateDistribution
Parameters:
outcome - Outcome whose probability is returned.
Returns:
The probability of the specified outcome.