com.aliasi.stats

## Class MultivariateDistribution

• All Implemented Interfaces:
DiscreteDistribution
Direct Known Subclasses:
BernoulliDistribution, MultivariateConstant, MultivariateEstimator

```public abstract class MultivariateDistribution
extends AbstractDiscreteDistribution```
A `MultivariateDistribution` implements a discrete distribution over a finite set of outcomes numbered consecutively from zero. The total number of outcomes is given by the abstract method `numDimensions()`. The minimum outcome is zero and the maximum outcome is the number of dimensions minus one. Concrete subclasses must also implement the method `probability(long)`.

Outcomes in multivariate distributions are labeled by strings. The method `label(long)` returns the label for an outcome. The inverse method `outcome(String)` maps labels to outcomes. The default implementation in this class provides labels defined by converting the long integer outcomes to strings. Subclasses may override these methods (together) to implement a more meaningful notion of label.

Note that the multivariate distribution forms the basis of the mulitnomial distribution. The Bernoulli distribution is a special case of the multivariate distribution with two outcomes.

Since:
LingPipe2.0
Version:
2.0
Author:
Bob Carpenter
• ### Constructor Summary

Constructors
Constructor and Description
`MultivariateDistribution()`
Construct a multivariate distribution.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`String` `label(long outcome)`
Return the label for the specified outcome.
`double` `log2Probability(String label)`
Returns the log (base 2) probability of the outcome specified by label.
`long` `maxOutcome()`
Returns the maximum outcome with non-zero probability for a multivariate distribution.
`long` `minOutcome()`
Returns zero, the minimum outcome with non-zero probability for a multivariate distribution.
`abstract int` `numDimensions()`
Returns the number of dimensions of this multivariate distribution.
`long` `outcome(String label)`
Return the outcome for the specified label.
`abstract double` `probability(long outcome)`
Return the probability of the specified outcome in this multivariate distribution.
`double` `probability(String label)`
Returns the probability of the outcome specified by label.
• ### 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

• #### MultivariateDistribution

`public MultivariateDistribution()`
Construct a multivariate distribution.
• ### Method Detail

• #### minOutcome

`public long minOutcome()`
Returns zero, the minimum outcome with non-zero probability for a multivariate distribution.
Specified by:
`minOutcome` in interface `DiscreteDistribution`
Overrides:
`minOutcome` in class `AbstractDiscreteDistribution`
Returns:
Zero.
• #### maxOutcome

`public long maxOutcome()`
Returns the maximum outcome with non-zero probability for a multivariate distribution. This method returns the number of dimensions as specified by `numDimensions()` minus one.
Specified by:
`maxOutcome` in interface `DiscreteDistribution`
Overrides:
`maxOutcome` in class `AbstractDiscreteDistribution`
Returns:
The maximum outcome with non-zero probability for this distribution.
• #### outcome

`public long outcome(String label)`
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.
Parameters:
`label` - Label whose outcome is returned.
Returns:
The outcome for the specified label.
• #### label

`public String label(long outcome)`
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.
Parameters:
`outcome` - Outcome whose label is returned.
Returns:
The label for the specified outcome.
Throws:
`IllegalArgumentException` - If the outcome index is out of range.
• #### probability

`public double probability(String label)`
Returns the probability of the outcome specified by label. If there is no known outcome with the specified label, this method will return `0.0`.
Parameters:
`label` - Label of outcome.
Returns:
The probability of the outcome specified by label.
• #### log2Probability

`public double log2Probability(String label)`
Returns the log (base 2) probability of the outcome specified by label. If there is no known outcome with the specified label, this method will return `Double.NEGATIVE_INFINITY`.
Parameters:
`label` - Label of outcome.
Returns:
The log probability of the outcome specified by label.
• #### numDimensions

`public abstract int numDimensions()`
Returns the number of dimensions of this multivariate distribution. Note that this must be a positive number.
Returns:
The number of dimensions for this distribution.
• #### probability

`public abstract double probability(long outcome)`
Return the probability of the specified outcome in this multivariate distribution.
Specified by:
`probability` in interface `DiscreteDistribution`
Specified by:
`probability` in class `AbstractDiscreteDistribution`
Parameters:
`outcome` - Outcome whose probability is returned.
Returns:
The probability of the specified outcome.