MixtureT Class 
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public class Mixture<T> : UnivariateContinuousDistribution, IMixture<T>, IDistribution, ICloneable, IFittableDistribution<double, MixtureOptions>, IFittable<double, MixtureOptions>, IFittable<double>, IFittableDistribution<double>, IDistribution<double>, ISampleableDistribution<double>, IRandomNumberGenerator<double> where T : Object, IUnivariateDistribution<double>
The MixtureT type exposes the following members.
Name  Description  

MixtureT(T) 
Initializes a new instance of the MixtureT class.
 
MixtureT(Double, T) 
Initializes a new instance of the MixtureT class.

Name  Description  

Coefficients 
Gets the weight coefficients.
 
Components 
Gets the mixture components.
 
Entropy 
This method is not supported.
(Overrides UnivariateContinuousDistributionEntropy.)  
Mean 
Gets the mean for this distribution.
(Overrides UnivariateContinuousDistributionMean.)  
Median 
Gets the median for this distribution.
(Inherited from UnivariateContinuousDistribution.)  
Mode 
This method is not supported.
(Overrides UnivariateContinuousDistributionMode.)  
Quartiles 
Gets the Quartiles for this distribution.
(Inherited from UnivariateContinuousDistribution.)  
StandardDeviation 
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateContinuousDistribution.)  
Support 
Gets the support interval for this distribution.
(Overrides UnivariateContinuousDistributionSupport.)  
Variance 
Gets the variance for this distribution.
(Overrides UnivariateContinuousDistributionVariance.) 
Name  Description  

Clone 
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)  
ComplementaryDistributionFunction 
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point x.
This function is also known as the Survival function.
(Inherited from UnivariateContinuousDistribution.)  
CumulativeHazardFunction 
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
DistributionFunction(Double) 
Gets the cumulative distribution function (cdf) for
this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionDistributionFunction(Double).)  
DistributionFunction(Int32, Double) 
Gets the cumulative distribution function (cdf) for one
component of this distribution evaluated at point x.
 
DistributionFunction(Double, Double) 
Gets the cumulative distribution function (cdf) for this
distribution in the semiclosed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateContinuousDistribution.)  
Equals  Determines whether the specified object is equal to the current object. (Inherited from Object.)  
Estimate(Double, T) 
Estimates a new mixture model from a given set of observations.
 
Estimate(Double, Double, T) 
Estimates a new mixture model from a given set of observations.
 
Estimate(Double, Double, Double, T) 
Estimates a new mixture model from a given set of observations.
 
Finalize  Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)  
Fit(Double) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Double) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Int32) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateContinuousDistributionFit(Double, Double, IFittingOptions).)  
Fit(Double, Double, MixtureOptions) 
Fits the underlying distribution to a given set of observations.
 
Fit(Double, Int32, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Generate 
Generates a random observation from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate.)  
Generate(Int32) 
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.)  
Generate(Int32, Double) 
Generates a random vector of observations from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate(Int32, Double).)  
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetRange 
Gets the distribution range within a given percentile.
(Inherited from UnivariateContinuousDistribution.)  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
HazardFunction 
Gets the hazard function, also known as the failure rate or
the conditional failure density function for this distribution
evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
InverseDistributionFunction 
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p. This function
is also known as the Quantile function.
(Inherited from UnivariateContinuousDistribution.)  
LogCumulativeHazardFunction 
Gets the log of the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
LogLikelihood(Double) 
Computes the loglikelihood of the distribution
for a given set of observations.
 
LogLikelihood(Double, Double) 
Computes the loglikelihood of the distribution
for a given set of observations.
 
LogProbabilityDensityFunction(Double) 
Gets the logprobability density function (pdf) for
this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionLogProbabilityDensityFunction(Double).)  
LogProbabilityDensityFunction(Int32, Double) 
Gets the logprobability density function (pdf) for one
of the component distributions evaluated at point x.
 
MemberwiseClone  Creates a shallow copy of the current Object. (Inherited from Object.)  
ProbabilityDensityFunction(Double) 
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionProbabilityDensityFunction(Double).)  
ProbabilityDensityFunction(Int32, Double) 
Gets the probability density function (pdf) for one of
the component distributions evaluated at point x.
 
QuantileDensityFunction 
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateContinuousDistribution.)  
ToString 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(IFormatProvider) 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(String) 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(String, IFormatProvider) 
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).) 
Name  Description  

HasMethod 
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by Matrix.) 
A mixture density is a probability density function which is expressed as a convex combination (i.e. a weighted sum, with nonnegative weights that sum to 1) of other probability density functions. The individual density functions that are combined to make the mixture density are called the mixture components, and the weights associated with each component are called the mixture weights.
References:
// Create a new mixture containing two Normal distributions Mixture<NormalDistribution> mix = new Mixture<NormalDistribution>( new NormalDistribution(2, 1), new NormalDistribution(5, 1)); // Common measures double mean = mix.Mean; // 3.5 double median = mix.Median; // 3.4999998506015895 double var = mix.Variance; // 3.25 // Cumulative distribution functions double cdf = mix.DistributionFunction(x: 4.2); // 0.59897597553494908 double ccdf = mix.ComplementaryDistributionFunction(x: 4.2); // 0.40102402446505092 // Probability mass functions double pmf1 = mix.ProbabilityDensityFunction(x: 1.2); // 0.14499174984363708 double pmf2 = mix.ProbabilityDensityFunction(x: 2.3); // 0.19590437513747333 double pmf3 = mix.ProbabilityDensityFunction(x: 3.7); // 0.13270883471234715 double lpmf = mix.LogProbabilityDensityFunction(x: 4.2); // 1.8165661905848629 // Quantile function double icdf1 = mix.InverseDistributionFunction(p: 0.17); // 1.5866611690305095 double icdf2 = mix.InverseDistributionFunction(p: 0.46); // 3.1968506765456883 double icdf3 = mix.InverseDistributionFunction(p: 0.87); // 5.6437596300843076 // Hazard (failure rate) functions double hf = mix.HazardFunction(x: 4.2); // 0.40541978256972522 double chf = mix.CumulativeHazardFunction(x: 4.2); // 0.91373394208601633 // String representation: // Mixture(x; 0.5 * N(x; μ = 5, σ² = 1) + 0.5 * N(x; μ = 5, σ² = 1)) string str = mix.ToString(CultureInfo.InvariantCulture);
The following example shows how to estimate (fit) a Mixture of Normal distributions from weighted data:
// Randomly initialize some mixture components NormalDistribution[] components = new NormalDistribution[2]; components[0] = new NormalDistribution(2, 1); components[1] = new NormalDistribution(5, 1); // Create an initial mixture var mixture = new Mixture<NormalDistribution>(components); // Now, suppose we have a weighted data // set. Those will be the input points: double[] points = { 0, 3, 1, 7, 3, 5, 1, 2, 1, 2, 7, 6, 8, 6 }; // (14 points) // And those are their respective unnormalized weights: double[] weights = { 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 3, 1, 1 }; // (14 weights) // Let's normalize the weights so they sum up to one: weights = weights.Divide(weights.Sum()); // Now we can fit our model to the data: mixture.Fit(points, weights); // done! // Our model will be: double mean1 = mixture.Components[0].Mean; // 1.41126 double mean2 = mixture.Components[1].Mean; // 6.53301 // With mixture weights double pi1 = mixture.Coefficients[0]; // 0.51408 double pi2 = mixture.Coefficients[0]; // 0.48591 // If we need the GaussianMixtureModel functionality, we can // use the estimated mixture to initialize a new model: GaussianMixtureModel gmm = new GaussianMixtureModel(mixture); mean1 = gmm.Gaussians[0].Mean[0]; // 1.41126 (same) mean2 = gmm.Gaussians[1].Mean[0]; // 6.53301 (same) p1 = gmm.Gaussians[0].Proportion; // 0.51408 (same) p2 = gmm.Gaussians[1].Proportion; // 0.48591 (same)