GeneralDiscreteDistribution Class |
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public sealed class GeneralDiscreteDistribution : UnivariateDiscreteDistribution, IUnivariateFittableDistribution, IFittableDistribution<double>, IFittable<double>, IDistribution<double>, IDistribution, ICloneable, IUnivariateDistribution<double>, IUnivariateDistribution, IFittableDistribution<double, GeneralDiscreteOptions>, IFittable<double, GeneralDiscreteOptions>, IFittableDistribution<double[], GeneralDiscreteOptions>, IFittable<double[], GeneralDiscreteOptions>, IFittable<double[]>, IFittableDistribution<double[]>, IDistribution<double[]>, IFittableDistribution<int, GeneralDiscreteOptions>, IFittable<int, GeneralDiscreteOptions>, IFittable<int>, IFittableDistribution<int>, IDistribution<int>, ISampleableDistribution<int>, IRandomNumberGenerator<int>, ISampleableDistribution<double>, IRandomNumberGenerator<double>
The GeneralDiscreteDistribution type exposes the following members.
Name | Description | |
---|---|---|
GeneralDiscreteDistribution(Double) |
Constructs a new generic discrete distribution.
| |
GeneralDiscreteDistribution(Boolean, Double) |
Constructs a new generic discrete distribution.
| |
GeneralDiscreteDistribution(Int32, Boolean) |
Constructs a new uniform discrete distribution.
| |
GeneralDiscreteDistribution(Int32, Double) |
Constructs a new generic discrete distribution.
| |
GeneralDiscreteDistribution(Int32, Int32, Boolean) |
Constructs a new uniform discrete distribution.
|
Name | Description | |
---|---|---|
Entropy |
Gets the entropy for this distribution.
(Overrides UnivariateDiscreteDistributionEntropy.) | |
Frequencies |
Gets the probabilities associated with each discrete variable value.
Note: if the frequencies in this property are manually changed, the
rest of the class properties (Mode, Mean, ...) will not be automatically
updated to reflect the actual inserted values.
| |
Item |
Gets the probability value associated with the symbol i.
| |
Length |
Gets the number of symbols in the distribution.
| |
Maximum |
Gets the integer value where the
discrete distribution ends.
| |
Mean |
Gets the mean for this distribution.
(Overrides UnivariateDiscreteDistributionMean.) | |
Median |
Gets the median for this distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Minimum |
Gets the integer value where the
discrete distribution starts.
| |
Mode |
Gets the mode for this distribution.
(Overrides UnivariateDiscreteDistributionMode.) | |
Quartiles |
Gets the Quartiles for this distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
StandardDeviation |
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Support |
Gets the support interval for this distribution.
(Overrides UnivariateDiscreteDistributionSupport.) | |
Variance |
Gets the variance for this distribution.
(Overrides UnivariateDiscreteDistributionVariance.) |
Name | Description | |
---|---|---|
Clone |
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.) | |
ComplementaryDistributionFunction(Int32) |
Gets P(X > k) the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.) | |
ComplementaryDistributionFunction(Int32, Boolean) |
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.) | |
CumulativeHazardFunction |
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32) |
Gets P(X ≤ k), the cumulative distribution function
(cdf) for this distribution evaluated at point k.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32, Boolean) |
Gets P(X ≤ k) or P(X < k), the cumulative distribution function
(cdf) for this distribution evaluated at point k, depending
on the value of the inclusive parameter.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32, Int32) |
Gets the cumulative distribution function (cdf) for this
distribution in the semi-closed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateDiscreteDistribution.) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Fit(Double) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Double) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Int32, Double) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Double, GeneralDiscreteOptions) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Double, Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Double, Double, IFittingOptions).) | |
Fit(Double, Double, GeneralDiscreteOptions) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Int32, Double, GeneralDiscreteOptions) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Int32, Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Int32, Double, IFittingOptions).) | |
Fit(Double, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
FromMatrix(Double, Boolean) |
Creates general discrete distributions given a matrix of symbol probabilities.
| |
FromMatrix(Double, Boolean) |
Creates general discrete distributions given a matrix of symbol probabilities.
| |
Generate |
Generates a random observation from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Random) |
Generates a random observation from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Random).) | |
Generate(Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Double) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Int32, Random) |
Generates a random vector of observations from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Int32, Int32, Random).) | |
Generate(Int32, Double, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetRange |
Gets the distribution range within a given percentile.
(Inherited from UnivariateDiscreteDistribution.) | |
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 UnivariateDiscreteDistribution.) | |
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 UnivariateDiscreteDistribution.) | |
LogCumulativeHazardFunction |
Gets the log-cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
LogProbabilityMassFunction |
Gets the log-probability mass function (pmf) for
this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
ProbabilityMassFunction |
Gets the probability mass function (pmf) for
this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
QuantileDensityFunction |
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateDiscreteDistribution.) | |
Random(Double, Boolean) |
Returns a random symbol within the given symbol probabilities.
| |
Random(Double, Int32) |
Returns a random sample within the given symbol probabilities.
| |
Random(Double, Int32, Random) |
Returns a random sample within the given symbol probabilities.
| |
Random(Double, Random, Boolean) |
Returns a random symbol within the given symbol probabilities.
| |
Random(Double, Int32, Int32, Boolean) |
Returns a random sample within the given symbol probabilities.
| |
Random(Double, Int32, Int32, Random, Boolean) |
Returns a random sample within the given symbol probabilities.
| |
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).) | |
Uniform |
Constructs a new uniform discrete distribution.
|
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | 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 ExtensionMethods.) |
An univariate categorical distribution is a statistical distribution whose variables can take on only discrete values. Each discrete value defined within the interval of the distribution has an associated probability value indicating its frequency of occurrence.
The discrete uniform distribution is a special case of a generic discrete distribution whose probability values are constant.
// Create a Categorical distribution for 3 symbols, in which // the first and second symbol have 25% chance of appearing, // and the third symbol has 50% chance of appearing. // 1st 2nd 3rd double[] probabilities = { 0.25, 0.25, 0.50 }; // Create the categorical with the given probabilities var dist = new GeneralDiscreteDistribution(probabilities); // Common measures double mean = dist.Mean; // 1.25 double median = dist.Median; // 1.00 double var = dist.Variance; // 0.6875 // Cumulative distribution functions double cdf = dist.DistributionFunction(k: 2); // 1.0 double ccdf = dist.ComplementaryDistributionFunction(k: 2); // 0.0 // Probability mass functions double pdf1 = dist.ProbabilityMassFunction(k: 0); // 0.25 double pdf2 = dist.ProbabilityMassFunction(k: 1); // 0.25 double pdf3 = dist.ProbabilityMassFunction(k: 2); // 0.50 double lpdf = dist.LogProbabilityMassFunction(k: 2); // -0.69314718055994529 // Quantile function int icdf1 = dist.InverseDistributionFunction(p: 0.17); // 0 int icdf2 = dist.InverseDistributionFunction(p: 0.39); // 1 int icdf3 = dist.InverseDistributionFunction(p: 0.56); // 2 // Hazard (failure rate) functions double hf = dist.HazardFunction(x: 0); // 0.33333333333333331 double chf = dist.CumulativeHazardFunction(x: 0); // 0.2876820724517809 // String representation string str = dist.ToString(CultureInfo.InvariantCulture); // "Categorical(x; p = { 0.25, 0.25, 0.5 })"