umontreal.iro.lecuyer.probdistmulti
Class MultinomialDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdistmulti.DiscreteDistributionIntMulti
-
- umontreal.iro.lecuyer.probdistmulti.MultinomialDist
-
public class MultinomialDist extends DiscreteDistributionIntMulti
Implements the abstract classDiscreteDistributionIntMultifor the multinomial distribution with parameters n and (p1, ...,pd). The probability mass function isP[X = (x1,..., xd)] = n!∏i=1dpixi/(∏i=1dxi!),where ∑i=1dxi = n and ∑i=1dpi = 1.
-
-
Constructor Summary
Constructors Constructor and Description MultinomialDist(int n, double[] p)Creates a MultinomialDist object with parameters n and (p1,...,pd) such that ∑i=1dpi = 1.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description doublecdf(int[] x)Computes the cumulative probability function F of the distribution evaluated at x, assuming the lowest values start at 0, i.e.static doublecdf(int n, double[] p, int[] x)Computes the function F of the multinomial distribution with parameters n and (p1,...,pd) evaluated at x.double[][]getCorrelation()Returns the correlation matrix of the distribution, defined as ρij = σij/(σ_iiσ_jj)1/2.static double[][]getCorrelation(int n, double[] p)Computes the correlation matrix of the multinomial distribution with parameters n and (p1,...,pd).double[][]getCovariance()Returns the variance-covariance matrix of the distribution, defined as
σij = E[(Xi - μi)(Xj - μj)].static double[][]getCovariance(int n, double[] p)Computes the covariance matrix of the multinomial distribution with parameters n and (p1,...,pd).static double[]getMaximumLikelihoodEstimate(int[][] x, int m, int d, int n)Deprecated.double[]getMean()Returns the mean vector of the distribution, defined as μi = E[Xi].static double[]getMean(int n, double[] p)Computes the mean E[Xi] = npi of the multinomial distribution with parameters n and (p1,...,pd).static double[]getMLE(int[][] x, int m, int d, int n)Estimates and returns the parameters [hat(p_i),...,hat(p_d)] of the multinomial distribution using the maximum likelihood method.intgetN()Returns the parameter n of this object.double[]getP()Returns the parameters (p1,...,pd) of this object.doubleprob(int[] x)Returns the probability mass function p(x1, x2,…, xd), which should be a real number in [0, 1].static doubleprob(int n, double[] p, int[] x)Computes the probability mass function of the multinomial distribution with parameters n and (p1,...,pd) evaluated at x.voidsetParams(int n, double[] p)Sets the parameters n and (p1,...,pd) of this object.-
Methods inherited from class umontreal.iro.lecuyer.probdistmulti.DiscreteDistributionIntMulti
getDimension
-
-
-
-
Constructor Detail
-
MultinomialDist
public MultinomialDist(int n, double[] p)Creates a MultinomialDist object with parameters n and (p1,...,pd) such that ∑i=1dpi = 1. We have pi = p[i-1].
-
-
Method Detail
-
prob
public double prob(int[] x)
Description copied from class:DiscreteDistributionIntMultiReturns the probability mass function p(x1, x2,…, xd), which should be a real number in [0, 1].- Specified by:
probin classDiscreteDistributionIntMulti- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(int[] x)
Description copied from class:DiscreteDistributionIntMultiComputes the cumulative probability function F of the distribution evaluated at x, assuming the lowest values start at 0, i.e. computesF(x1, x2,…, xd) = ∑s1=0x1∑s2=0x2 ... ∑sd=0xdp(s1, s2,…, sd).Uses the naive implementation, is very inefficient and may underflows.- Overrides:
cdfin classDiscreteDistributionIntMulti
-
getMean
public double[] getMean()
Description copied from class:DiscreteDistributionIntMultiReturns the mean vector of the distribution, defined as μi = E[Xi].- Specified by:
getMeanin classDiscreteDistributionIntMulti
-
getCovariance
public double[][] getCovariance()
Description copied from class:DiscreteDistributionIntMultiReturns the variance-covariance matrix of the distribution, defined as
σij = E[(Xi - μi)(Xj - μj)].- Specified by:
getCovariancein classDiscreteDistributionIntMulti
-
getCorrelation
public double[][] getCorrelation()
Description copied from class:DiscreteDistributionIntMultiReturns the correlation matrix of the distribution, defined as ρij = σij/(σ_iiσ_jj)1/2.- Specified by:
getCorrelationin classDiscreteDistributionIntMulti
-
prob
public static double prob(int n, double[] p, int[] x)Computes the probability mass function of the multinomial distribution with parameters n and (p1,...,pd) evaluated at x.
-
cdf
public static double cdf(int n, double[] p, int[] x)Computes the function F of the multinomial distribution with parameters n and (p1,...,pd) evaluated at x.
-
getMean
public static double[] getMean(int n, double[] p)Computes the mean E[Xi] = npi of the multinomial distribution with parameters n and (p1,...,pd).
-
getCovariance
public static double[][] getCovariance(int n, double[] p)Computes the covariance matrix of the multinomial distribution with parameters n and (p1,...,pd).
-
getCorrelation
public static double[][] getCorrelation(int n, double[] p)Computes the correlation matrix of the multinomial distribution with parameters n and (p1,...,pd).
-
getMaximumLikelihoodEstimate
@Deprecated public static double[] getMaximumLikelihoodEstimate(int[][] x, int m, int d, int n)Deprecated.It is now called getMLE.
-
getMLE
public static double[] getMLE(int[][] x, int m, int d, int n)Estimates and returns the parameters [hat(p_i),...,hat(p_d)] of the multinomial distribution using the maximum likelihood method. It uses the m observations of d components in table x[i][j], i = 0, 1,…, m - 1 and j = 0, 1,…, d - 1.- Parameters:
x- the list of observations used to evaluate parametersm- the number of observations used to evaluate parametersd- the dimension of each observationn- the number of independant trials for each series- Returns:
- returns the parameters [hat(p_i),...,hat(p_d)]
-
getN
public int getN()
Returns the parameter n of this object.
-
getP
public double[] getP()
Returns the parameters (p1,...,pd) of this object.
-
setParams
public void setParams(int n, double[] p)Sets the parameters n and (p1,...,pd) of this object.
-
-
DMelt 3.0 © DataMelt by jWork.ORG