edu.ucla.stat.SOCR.distributions
Class MixtureDistribution

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.MixtureDistribution
All Implemented Interfaces:
IValueSettable, Pluginable, java.awt.event.ActionListener, java.util.EventListener, java.util.Observer

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

The Mixture distribution with parameter-vector p=(p1, p2, ..., pn) http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_2D_PointSegmentation_EM_Mixture is the (linear) mixure of an array of distributions according to the mixing parameters.


Field Summary
 
Fields inherited from class edu.ucla.stat.SOCR.core.Distribution
applet, CONTINUOUS, DISCRETE, MAXMGFXVAL, MAXMGFYVAL, MINMGFXVAL, MIXED, name
 
Constructor Summary
MixtureDistribution()
          This default constructor creates the mixture of two standard normal distributions with equal mixing parameters.
MixtureDistribution(Distribution[] d, double[] p)
          This general constructor creates the mixture of a given array of distributitons using a given array of probabilities as the mixing parameters.
MixtureDistribution(Distribution d0, Distribution d1)
          This special constructor creates the mixture of two distributions with equal mixing probabilities
MixtureDistribution(Distribution d0, Distribution d1, double a)
          This special constructor creates the mixture of two distributions using a specified number and its complement as the mixing probabilities.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method handles the events associated with the die probabilities button and with the step timer.
 double getCDF(double x)
          This method computes the cumulative distributions function of the mixture distributions as a linear combination of the CDFs of the given distributions, using the mixing probabilities.
 double getDensity(double x)
          This method computes the density function of the mixture distributions as a linear combination of the densities of the given distributions using the mixing probabilities.
 Distribution[] getDistributions()
          This method returns the array of distributions.
 Distribution getDistributions(int i)
          This method returns a particular distribution.
 double getMean()
          This method computes the mean of the mixture distributions as a linear combination of the means of the given distributions, using the mixing probabilities.
 double[][] getMeansSDsWeights()
          This method gets up the 3 arrays of mixture parameters (Means[], SDs[] and Weights[]).
 java.lang.String getOnlineDescription()
          This method returns an online description of this distribution.
 double[] getProbabilities()
          This method returns the array of probabilities.
 double getProbability(int i)
          This method returns a particular probability .
 double getVariance()
          This method computes the variance of the mixture distributions in terms of the variances and means of the given distributions and the mixing parameters.
 void initialize()
          used for some subclass to initialize before being used
 void setDistributions(Distribution[] d)
          This method sets the distributions.
 void setDistributions(int i, Distribution d)
          This method sets a particular distribution.
 void setMeansSDsWeights(double[] _means, double[] _SDs, double[] _weights)
          This method sets up the 3 arrays of mixture parameters (Means[], SDs[] and Weights[]).
 void setParameters(Distribution[] d, double[] p)
          This method sets up the domain of the general mixture distributions in terms of the distributions being mixed.
 void setParameters(Distribution d0, Distribution d1, double a)
          This method sets up the domain of for the mixture of two distributions.
 void setProbabilities(double[] p)
          This method sets the probabilities.
 void setProbabilities(int i, double p)
          This method sets a particular probability.
 double simulate()
          This method simulates a value from the mixture distributions.
 void valueChanged()
           
 
Methods inherited from class edu.ucla.stat.SOCR.core.Distribution
addObserver, betaCDF, comb, factorial, findGFRoot, findRoot, gamma, gammaCDF, getDisplayPane, getDomain, getFailureRate, getGFDerivative, getGFSecondDerivative, getInstance, getLocalHelp, getMaxDensity, getMean, getMedian, getMGF, getMgfDomain, getName, getPGF, getPGFDomain, getQuantile, getSampleMoment, getSD, getSOCRDistributionFunctors, getSOCRDistributions, getType, getVariance, inverseCDF, logGamma, paramEstimate, perm, sampleMean, sampleVar, setApplet, setDomain, setDomain, setMGFDomain, setMGFDomain, setMGFParameters, setMGFParameters, setMGFParameters, setMGFParameters, setParameters, setPGFDomain, setPGFDomain, setPGFParameters, setPGFParameters, setPGFParameters, setPGFParameters, 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
 

Constructor Detail

MixtureDistribution

public MixtureDistribution(Distribution[] d,
                           double[] p)
This general constructor creates the mixture of a given array of distributitons using a given array of probabilities as the mixing parameters.

Parameters:
d - the array of distributions to be mixed
p - the array of mixing probabilities

MixtureDistribution

public MixtureDistribution(Distribution d0,
                           Distribution d1,
                           double a)
This special constructor creates the mixture of two distributions using a specified number and its complement as the mixing probabilities.

Parameters:
d0 - the index 0 distributions
d1 - the index 1 distributions
a - the index 1 mixing parameter (the index 0 parameter is 1 − a)

MixtureDistribution

public MixtureDistribution(Distribution d0,
                           Distribution d1)
This special constructor creates the mixture of two distributions with equal mixing probabilities

Parameters:
d0 - the index 0 distribution
d1 - the index 1 distribution

MixtureDistribution

public MixtureDistribution()
This default constructor creates the mixture of two standard normal distributions with equal mixing parameters. The result is simply another standard normal distribution.

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 die probabilities button and with the step timer. If the die probability button is pressed, the current die probabilities are loaded into the dialog box which is then displayed. For the step timer, the dice are shown one at a time.

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

setParameters

public void setParameters(Distribution[] d,
                          double[] p)
This method sets up the domain of the general mixture distributions in terms of the distributions being mixed.

Parameters:
d - the array of distributions being mixed
p - the array of mixing probabilities

getMeansSDsWeights

public double[][] getMeansSDsWeights()
This method gets up the 3 arrays of mixture parameters (Means[], SDs[] and Weights[]).

Parameters:
means - the arrays of the means of the Normal Distributions in the mixture
SDs - the arrays of the Standard-Deviations of the Normal Distributions in the mixture
weights - the arrays of the weights of the Normal Distributions in the mixture

setMeansSDsWeights

public void setMeansSDsWeights(double[] _means,
                               double[] _SDs,
                               double[] _weights)
This method sets up the 3 arrays of mixture parameters (Means[], SDs[] and Weights[]).

Parameters:
means - the arrays of the means of the Normal Distributions in the mixture
SDs - the arrays of the Standard-Deviations of the Normal Distributions in the mixture
weights - the arrays of the weights of the Normal Distributions in the mixture

setParameters

public void setParameters(Distribution d0,
                          Distribution d1,
                          double a)
This method sets up the domain of for the mixture of two distributions.

Parameters:
d0 - the index 0 distributions
d1 - the index 1 distributions
a - the index 1 mixing parameter (the index 0 parameter is 1 − a)

getDensity

public double getDensity(double x)
This method computes the density function of the mixture distributions as a linear combination of the densities of the given distributions using the mixing probabilities.

Specified by:
getDensity in class Distribution
Parameters:
x - a number in the domain of the distributions
Returns:
the probability density at x

getCDF

public double getCDF(double x)
This method computes the cumulative distributions function of the mixture distributions as a linear combination of the CDFs of the given distributions, using the mixing probabilities.

Overrides:
getCDF in class Distribution

getMean

public double getMean()
This method computes the mean of the mixture distributions as a linear combination of the means of the given distributions, using the mixing probabilities.

Overrides:
getMean in class Distribution
Returns:
the mean

getVariance

public double getVariance()
This method computes the variance of the mixture distributions in terms of the variances and means of the given distributions and the mixing parameters.

Overrides:
getVariance in class Distribution
Returns:
the variance

simulate

public double simulate()
This method simulates a value from the mixture distributions. This is done by selecting an index at random, according to the mixing parameters, and then simulating a value from the randomly chosen distributions.

Overrides:
simulate in class Distribution

setDistributions

public void setDistributions(Distribution[] d)
This method sets the distributions.

Parameters:
d - the array of distributions

setDistributions

public void setDistributions(int i,
                             Distribution d)
This method sets a particular distribution.

Parameters:
i - the index
d - the distribution

getDistributions

public Distribution[] getDistributions()
This method returns the array of distributions.

Returns:
the array of distributions

getDistributions

public Distribution getDistributions(int i)
This method returns a particular distribution.

Parameters:
i - the index
Returns:
the distribution corresponding to the index

setProbabilities

public void setProbabilities(double[] p)
This method sets the probabilities.

Parameters:
p - the array of probabilities

setProbabilities

public void setProbabilities(int i,
                             double p)
This method sets a particular probability.

Parameters:
i - the index
p - the probability

getProbabilities

public double[] getProbabilities()
This method returns the array of probabilities.

Returns:
the array of distributions

getProbability

public double getProbability(int i)
This method returns a particular probability .

Parameters:
i - the index
Returns:
the probability corresponding to the index

getOnlineDescription

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

Overrides:
getOnlineDescription in class Distribution