Click or drag to resize
Accord.NET (logo)

HypergeometricDistribution Class

Hypergeometric probability distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.UnivariateUnivariateDiscreteDistribution
      Accord.Statistics.Distributions.UnivariateHypergeometricDistribution

Namespace:  Accord.Statistics.Distributions.Univariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class HypergeometricDistribution : UnivariateDiscreteDistribution, 
	IFittableDistribution<double, HypergeometricOptions>, IFittable<double, HypergeometricOptions>, 
	IFittable<double>, IFittableDistribution<double>, IDistribution<double>, 
	IDistribution, ICloneable
Request Example View Source

The HypergeometricDistribution type exposes the following members.

Constructors
  NameDescription
Public methodHypergeometricDistribution
Constructs a new Hypergeometric distribution. To build from the number of failures and succcesses like in R, please see FromSuccessCounts(Int32, Int32, Int32).
Top
Properties
  NameDescription
Public propertyEntropy
Gets the entropy for this distribution.
(Overrides UnivariateDiscreteDistributionEntropy.)
Public propertyMean
Gets the mean for this distribution.
(Overrides UnivariateDiscreteDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertyMode
Gets the mode for this distribution.
(Overrides UnivariateDiscreteDistributionMode.)
Public propertyPopulationSize
Gets the size N of the population for this distribution.
Public propertyPopulationSuccess
Gets the count of success trials in the population for this distribution. This is often referred as m.
Public propertyQuartiles
Gets the Quartiles for this distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertySampleSize
Gets the size n of the sample drawn from N.
Public propertyStandardDeviation
Gets the Standard Deviation (the square root of the variance) for the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertySupport
Gets the support interval for this distribution.
(Overrides UnivariateDiscreteDistributionSupport.)
Public propertyVariance
Gets the variance for this distribution.
(Overrides UnivariateDiscreteDistributionVariance.)
Top
Methods
  NameDescription
Protected methodBaseDistributionFunction
Computes the cumulative distribution function by summing the outputs of the ProbabilityMassFunction(Int32) for all elements in the distribution domain. Note that this method should not be used in case there is a more efficient formula for computing the CDF of a distribution.
(Inherited from UnivariateDiscreteDistribution.)
Protected methodBaseInverseDistributionFunction
Gets the inverse of the cumulative distribution function (icdf) for this distribution evaluated at probability p using a numerical approximation based on binary search.
(Inherited from UnivariateDiscreteDistribution.)
Public methodClone
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)
Public methodComplementaryDistributionFunction(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.)
Public methodCode exampleComplementaryDistributionFunction(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.)
Public methodCumulativeHazardFunction
Gets the cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodDistributionFunction(Int32)
Gets P(X ≤ k), the cumulative distribution function (cdf) for this distribution evaluated at point k.
(Inherited from UnivariateDiscreteDistribution.)
Public methodCode exampleDistributionFunction(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.)
Public methodDistributionFunction(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.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Double, HypergeometricOptions)
Fits the underlying distribution to a given set of observations.
Public methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodStatic memberFromSuccessCounts
Creates a new HypergeometricDistribution from the number of successes, failures, and the number of samples drawn. This is the same parameterization used in R.
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Random)
Generates a random observation from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double, Random)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetRange
Gets the distribution range within a given percentile.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHazardFunction
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.)
Protected methodInnerComplementaryDistributionFunction
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.)
Protected methodInnerDistributionFunction
Gets the cumulative distribution function (cdf) for this distribution evaluated at point k.
(Overrides UnivariateDiscreteDistributionInnerDistributionFunction(Int32).)
Protected methodInnerInverseDistributionFunction
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.)
Protected methodInnerLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionInnerLogProbabilityMassFunction(Int32).)
Protected methodInnerProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionInnerProbabilityMassFunction(Int32).)
Public methodInverseDistributionFunction
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.)
Public methodLogCumulativeHazardFunction
Gets the log-cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodQuantileDensityFunction
Gets the first derivative of the inverse distribution function (icdf) for this distribution evaluated at probability p.
(Inherited from UnivariateDiscreteDistribution.)
Public methodToString
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(IFormatProvider)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String, IFormatProvider)
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(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.)
Public Extension MethodToTOverloaded.
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.)
Top
Remarks

The hypergeometric distribution is a discrete probability distribution that describes the probability of k successes in n draws from a finite population without replacement. This is in contrast to the binomial distribution, which describes the probability of k successes in n draws with replacement.

References:

Examples
// Distribution parameters
int populationSize = 15; // population size N
int success = 7;         // number of successes in the sample  
int samples = 8;         // number of samples drawn from N

// Create a new Hypergeometric distribution with N = 15, n = 8, and s = 7
var dist = new HypergeometricDistribution(populationSize, success, samples);

// Common measures
double mean   = dist.Mean;     // 1.3809523809523812
double median = dist.Median;   // 4.0
double var    = dist.Variance; // 3.2879818594104315
double mode   = dist.Mode;     // 4.0

// Cumulative distribution functions
double cdf = dist.DistributionFunction(k: 2);               // 0.80488799999999994
double ccdf = dist.ComplementaryDistributionFunction(k: 2); // 0.19511200000000006

// Probability mass functions
double pdf1 = dist.ProbabilityMassFunction(k: 4); // 0.38073038073038074
double pdf2 = dist.ProbabilityMassFunction(k: 5); // 0.18275058275058276
double pdf3 = dist.ProbabilityMassFunction(k: 6); // 0.030458430458430458
double lpdf = dist.LogProbabilityMassFunction(k: 2); // -2.3927801721315989

// Quantile function
int icdf1 = dist.InverseDistributionFunction(p: 0.17); // 3
int icdf2 = dist.InverseDistributionFunction(p: 0.46); // 4
int icdf3 = dist.InverseDistributionFunction(p: 0.87); // 5

// Hazard (failure rate) functions
double hf = dist.HazardFunction(x: 4); // 1.7753623188405792
double chf = dist.CumulativeHazardFunction(x: 4); // 1.5396683418789763

// String representation
string str = dist.ToString(CultureInfo.InvariantCulture); // "HyperGeometric(x; N = 15, m = 7, n = 8)"
See Also