edu.ucla.stat.SOCR.distributions
Class MultiNomialDistribution

java.lang.Object
  extended by edu.ucla.stat.SOCR.core.SOCRValueSettable
      extended by edu.ucla.stat.SOCR.core.Distribution
          extended by edu.ucla.stat.SOCR.distributions.MultiNomialDistribution
All Implemented Interfaces:
IValueSettable, Pluginable, java.awt.event.ActionListener, java.util.EventListener, java.util.Observer

public class MultiNomialDistribution
extends Distribution
implements java.awt.event.ActionListener

The Multinomial distribution with parameter-vector (k,p), where n=number of trials and event-probabilities p=(p1, p2, ..., pn), with sum(p_k)=1 and p_k>=0, 1<=k<=n. http://en.wikipedia.org/wiki/Multinomial_distribution is a generalization of the binomial distribution.


Field Summary
protected  int k
           
protected  int n
           
protected  double[] p
           
 int type
           
protected  int[] x
           
 
Fields inherited from class edu.ucla.stat.SOCR.core.Distribution
applet, CONTINUOUS, DISCRETE, MAXMGFXVAL, MAXMGFYVAL, MINMGFXVAL, MIXED, name
 
Constructor Summary
MultiNomialDistribution()
          This default constructor creates a new MultiNomialDistribution(2, {0.5, 0.5})
MultiNomialDistribution(int n, double[] p, int[] x)
          This general constructor creates a new MultiNomialDistribution with specified parameters:
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method handles the events associated with the changing the Multinomial probabilities or x-values.
 double getCDF(int[] x)
           
static double getCDF(int n, double[] p, int[] x)
          http://controls.engin.umich.edu/wiki/index.php/Multinomial_distributions
 double[][] getCorrelation()
           
static double[][] getCorrelation(int n, double[] p)
           
 double[][] getCovariance()
          This method returns the variance-covariance matrix of the Multinomail distribution, which is defined as sigma(i,j) = E[(Xi - mu(i))(Xj - mu(j))].
static double[][] getCovariance(int n, double[] p)
           
 double getDensity(double x)
          Define the Multinomial getDensity function
 double getDensity(int[] x)
          This method computes the density function of the Multinomail distribution
static double[] getMean(int n, double[] p)
           
static double[] getMLE(int[][] x, int m, int d, int n)
          This method returns the array of MLE estimates for the Mulinomial Probabilities.
 java.lang.String getMultiNomialTestResults()
          This method returns a Text Array with All cumulative Multinomial results
 int getN()
           
 java.lang.String getOnlineDescription()
          This method returns an online description of this distribution.
 double[] getP()
           
 double[] getProbabilities()
          This method gets the array of Multinomail parameters (probabilities[]).
 double getProbability(int[] x)
           
static double getProbability(int n, double[] p, int[] x)
          This method computes the density function of the Multinomail distribution
 int[] getXvalues()
          This method gets the array of Multinomail parameters (x-Values[]).
 int getXvaluesSum()
          This method gets the array of Multinomail parameters (x-Values[]).
 void initialize()
          used for some subclass to initialize before being used
 void setParameters(int n, double[] p, int[] x)
           
 void valueChanged()
           
 
Methods inherited from class edu.ucla.stat.SOCR.core.Distribution
addObserver, betaCDF, comb, factorial, findGFRoot, findRoot, gamma, gammaCDF, getCDF, getDisplayPane, getDomain, getFailureRate, getGFDerivative, getGFSecondDerivative, getInstance, getLocalHelp, getMaxDensity, getMean, getMean, getMedian, getMGF, getMgfDomain, getName, getPGF, getPGFDomain, getQuantile, getSampleMoment, getSD, getSOCRDistributionFunctors, getSOCRDistributions, getType, getVariance, getVariance, inverseCDF, logGamma, paramEstimate, perm, sampleMean, sampleVar, setApplet, setDomain, setDomain, setMGFDomain, setMGFDomain, setMGFParameters, setMGFParameters, setMGFParameters, setMGFParameters, setParameters, setPGFDomain, setPGFDomain, setPGFParameters, setPGFParameters, setPGFParameters, setPGFParameters, simulate, update, valueChanged
 
Methods inherited from class edu.ucla.stat.SOCR.core.SOCRValueSettable
createComponentSetter, createValueSetter, createValueSetter, createValueSetter, createValueSetter, getComponentSetter, getComponentSetters, getValueSetter, getValueSetters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

protected int k

n

protected int n

p

protected double[] p

x

protected int[] x

type

public int type
Constructor Detail

MultiNomialDistribution

public MultiNomialDistribution(int n,
                               double[] p,
                               int[] x)
This general constructor creates a new MultiNomialDistribution with specified parameters:

Parameters:
n - Total Sum of X-values (Frequencies)
p - array of Probabilities/likelihoods of all outcomes

MultiNomialDistribution

public MultiNomialDistribution()
This default constructor creates a new MultiNomialDistribution(2, {0.5, 0.5})

Method Detail

initialize

public void initialize()
Description copied from class: Distribution
used for some subclass to initialize before being used

Overrides:
initialize in class Distribution

valueChanged

public void valueChanged()
Overrides:
valueChanged in class Distribution

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method handles the events associated with the changing the Multinomial probabilities or x-values.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the action event

getProbabilities

public double[] getProbabilities()
This method gets the array of Multinomail parameters (probabilities[]).

Parameters:
probabilities - the array of the probailities of the Multinomial Distributions

getXvalues

public int[] getXvalues()
This method gets the array of Multinomail parameters (x-Values[]).

Returns:
xValues the array of the X-values of the Multinomial Distributions

getXvaluesSum

public int getXvaluesSum()
This method gets the array of Multinomail parameters (x-Values[]).

Returns:
xValuesSum the Sum of the array of the X-values of the Multinomial Distributions

getProbability

public double getProbability(int[] x)

getDensity

public double getDensity(double x)
Define the Multinomial getDensity function

Specified by:
getDensity in class Distribution

getN

public int getN()

getP

public double[] getP()

getCDF

public double getCDF(int[] x)

getCovariance

public double[][] getCovariance()
This method returns the variance-covariance matrix of the Multinomail distribution, which is defined as sigma(i,j) = E[(Xi - mu(i))(Xj - mu(j))].

Returns:
VarianceMatrix variance-covariance matrix of the Multinomial Distributions

getCorrelation

public double[][] getCorrelation()

getDensity

public double getDensity(int[] x)
This method computes the density function of the Multinomail distribution

Parameters:
x - a vector of outcomes i
Returns:
the probability density of the vector x

getProbability

public static double getProbability(int n,
                                    double[] p,
                                    int[] x)
This method computes the density function of the Multinomail distribution

Parameters:
n - Total sum ov x-values vector (total frequencies
p - multinomial probabilities
x - X-values (frequency) vector
Returns:
CDF CDF value

getCDF

public static double getCDF(int n,
                            double[] p,
                            int[] x)
http://controls.engin.umich.edu/wiki/index.php/Multinomial_distributions

Parameters:
n - total sum of the x-value (frequency) vector
p - Multinomial Probabilities
x - X-values (frequencies)
Returns:
CDF CDF value

getMean

public static double[] getMean(int n,
                               double[] p)

getCovariance

public static double[][] getCovariance(int n,
                                       double[] p)

getCorrelation

public static double[][] getCorrelation(int n,
                                        double[] p)

getMultiNomialTestResults

public java.lang.String getMultiNomialTestResults()
This method returns a Text Array with All cumulative Multinomial results


getMLE

public static double[] getMLE(int[][] x,
                              int m,
                              int d,
                              int n)
This method returns the array of MLE estimates for the Mulinomial Probabilities.

Parameters:
x - double array of X-values -- list of observations used to evaluate prob-parameters
m - the number of observations used to evaluate parameters
d - the dimension of each observation
n - the number of independent trials for each series
Returns:
probabilities the array of the probailities of the Multinomial Distributions (P-hat vector)

setParameters

public void setParameters(int n,
                          double[] p,
                          int[] x)

getOnlineDescription

public java.lang.String getOnlineDescription()
This method returns an online description of this distribution.

Overrides:
getOnlineDescription in class Distribution