smile.stat.distribution
Class GeometricDistribution
- java.lang.Object
-
- smile.stat.distribution.AbstractDistribution
-
- smile.stat.distribution.DiscreteDistribution
-
- smile.stat.distribution.GeometricDistribution
-
- All Implemented Interfaces:
- DiscreteExponentialFamily, Distribution
public class GeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily
The geometric distribution is a discrete probability distribution of the number X of Bernoulli trials needed to get one success, supported on the set {1, 2, 3, …}. Sometimes, people define that the probability distribution of the number Y = X - 1 of failures before the first success, supported on the set {0, 1, 2, 3, …}. To reduce the confusion, we denote the later as shifted geometric distribution. If the probability of success on each trial is p, then the probability that the k-th trial (out of k trials) is the first success is Pr(X = k) = (1 - p)k-1 p.Like its continuous analogue (the exponential distribution), the geometric distribution is memoryless. That means that if you intend to repeat an experiment until the first success, then, given that the first success has not yet occurred, the conditional probability distribution of the number of additional trials does not depend on how many failures have been observed. The geometric distribution is in fact the only memoryless discrete distribution.
Among all discrete probability distributions supported on {1, 2, 3, …} with given expected value μ, the geometric distribution X with parameter p = 1/μ is the one with the largest entropy.
- See Also:
ShiftedGeometricDistribution
-
-
Constructor Summary
Constructors Constructor and Description GeometricDistribution(double p)Constructor.GeometricDistribution(int[] data)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecdf(double k)Cumulative distribution function.doubleentropy()Shannon entropy.doublegetProb()Returns the probability of success.doublelogp(int k)The probability mass function in log scale.DiscreteMixture.ComponentM(int[] x, double[] posteriori)The M step in the EM algorithm, which depends the specific distribution.doublemean()The mean of distribution.intnpara()The number of parameters of the distribution.doublep(int k)The probability mass function.doublequantile(double p)The quantile, the probability to the left of quantile is p.doublerand()Generates a random number following this distribution.doublesd()The standard deviation of distribution.java.lang.StringtoString()doublevar()The variance of distribution.-
Methods inherited from class smile.stat.distribution.DiscreteDistribution
likelihood, logLikelihood, logp, p
-
Methods inherited from class smile.stat.distribution.AbstractDistribution
likelihood, logLikelihood
-
-
-
-
Constructor Detail
-
GeometricDistribution
public GeometricDistribution(double p)
Constructor.- Parameters:
p- the probability of success.
-
GeometricDistribution
public GeometricDistribution(int[] data)
Constructor. Parameter will be estimated from the data by MLE.
-
-
Method Detail
-
getProb
public double getProb()
Returns the probability of success.
-
npara
public int npara()
Description copied from interface:DistributionThe number of parameters of the distribution.- Specified by:
nparain interfaceDistribution
-
mean
public double mean()
Description copied from interface:DistributionThe mean of distribution.- Specified by:
meanin interfaceDistribution
-
var
public double var()
Description copied from interface:DistributionThe variance of distribution.- Specified by:
varin interfaceDistribution
-
sd
public double sd()
Description copied from interface:DistributionThe standard deviation of distribution.- Specified by:
sdin interfaceDistribution
-
entropy
public double entropy()
Shannon entropy. Not supported.- Specified by:
entropyin interfaceDistribution
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
rand
public double rand()
Description copied from interface:DistributionGenerates a random number following this distribution.- Specified by:
randin interfaceDistribution
-
p
public double p(int k)
Description copied from class:DiscreteDistributionThe probability mass function.- Specified by:
pin classDiscreteDistribution
-
logp
public double logp(int k)
Description copied from class:DiscreteDistributionThe probability mass function in log scale.- Specified by:
logpin classDiscreteDistribution
-
cdf
public double cdf(double k)
Description copied from interface:DistributionCumulative distribution function. That is the probability to the left of x.- Specified by:
cdfin interfaceDistribution
-
quantile
public double quantile(double p)
Description copied from interface:DistributionThe quantile, the probability to the left of quantile is p. It is actually the inverse of cdf.- Specified by:
quantilein interfaceDistribution
-
M
public DiscreteMixture.Component M(int[] x, double[] posteriori)
Description copied from interface:DiscreteExponentialFamilyThe M step in the EM algorithm, which depends the specific distribution.- Specified by:
Min interfaceDiscreteExponentialFamily- Parameters:
x- the input data for estimationposteriori- the posteriori probability.- Returns:
- the (unnormalized) weight of this distribution in the mixture.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG