Package smile.stat.distribution
Class DiscreteMixture
java.lang.Object
smile.stat.distribution.DiscreteDistribution
smile.stat.distribution.DiscreteMixture
- All Implemented Interfaces:
Serializable
,Distribution
- Direct Known Subclasses:
DiscreteExponentialFamilyMixture
The finite mixture of discrete distributions.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A component in the mixture distribution is defined by a distribution and its weight in the mixture. -
Field Summary
Modifier and TypeFieldDescriptionfinal DiscreteMixture.Component[]
The components of finite mixture model. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
bic
(double[] data) Returns the BIC score.double
cdf
(double x) Cumulative distribution function.double
entropy()
Shannon's entropy.int
length()
Returns the number of parameters of the distribution.double
logp
(int x) The probability mass function in log scale.int
map
(int x) Returns the index of component with maximum a posteriori probability.double
mean()
Returns the mean of distribution.double
p
(int x) The probability mass function.double[]
posteriori
(int x) Returns the posteriori probabilities.double
quantile
(double p) The quantile, the probability to the left of quantile is p.double
rand()
Generates a random number following this distribution.int
size()
Returns the number of components in the mixture.toString()
double
variance()
Returns the variance of distribution.Methods inherited from class smile.stat.distribution.DiscreteDistribution
likelihood, logLikelihood, logp, p, quantile, randi, randi
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.stat.distribution.Distribution
inverseTransformSampling, likelihood, logLikelihood, quantile, quantile, rand, rejectionSampling, sd
-
Field Details
-
components
The components of finite mixture model.
-
-
Constructor Details
-
DiscreteMixture
Constructor.- Parameters:
components
- a list of discrete distributions.
-
-
Method Details
-
posteriori
public double[] posteriori(int x) Returns the posteriori probabilities.- Parameters:
x
- an integer value.- Returns:
- the posteriori probabilities.
-
map
public int map(int x) Returns the index of component with maximum a posteriori probability.- Parameters:
x
- an integer value.- Returns:
- the index of component with maximum a posteriori probability.
-
mean
public double mean()Description copied from interface:Distribution
Returns the mean of distribution.- Returns:
- The mean.
-
variance
public double variance()Description copied from interface:Distribution
Returns the variance of distribution.- Returns:
- The variance.
-
entropy
public double entropy()Shannon's entropy. Not supported.- Returns:
- Shannon entropy.
-
p
public double p(int x) Description copied from class:DiscreteDistribution
The probability mass function.- Specified by:
p
in classDiscreteDistribution
- Parameters:
x
- a real value.- Returns:
- the probability.
-
logp
public double logp(int x) Description copied from class:DiscreteDistribution
The probability mass function in log scale.- Specified by:
logp
in classDiscreteDistribution
- Parameters:
x
- a real value.- Returns:
- the log probability.
-
cdf
public double cdf(double x) Description copied from interface:Distribution
Cumulative distribution function. That is the probability to the left of x.- Parameters:
x
- a real number.- Returns:
- the probability.
-
rand
public double rand()Description copied from interface:Distribution
Generates a random number following this distribution.- Returns:
- a random number.
-
quantile
public double quantile(double p) Description copied from interface:Distribution
The quantile, the probability to the left of quantile is p. It is actually the inverse of cdf.- Parameters:
p
- the probability.- Returns:
- the quantile.
-
length
public int length()Description copied from interface:Distribution
Returns the number of parameters of the distribution. The "length" is in the sense of the minimum description length principle.- Returns:
- The number of parameters.
-
size
public int size()Returns the number of components in the mixture.- Returns:
- the number of components in the mixture.
-
bic
public double bic(double[] data) Returns the BIC score.- Parameters:
data
- the data to calculate likelihood.- Returns:
- the BIC score.
-
toString
-