📜  scipy stats.gausshyper() | Python(1)

📅  最后修改于: 2023-12-03 15:20:00.257000             🧑  作者: Mango

scipy.stats.gausshyper() | Python

The scipy.stats.gausshyper() function is a part of the stats module in the SciPy library of Python. This function provides a probability distribution object for the Gauss hypergeometric distribution.

Gaussian Hypergeometric Distribution

The Gauss hypergeometric distribution represents a hypergeometric distribution generalized using a normalizing factor. It is a continuous probability distribution defined on the interval [0, 1].

Usage

To use the scipy.stats.gausshyper() function, you first need to import the stats module from the SciPy library:

from scipy import stats

Then, you can create a probability distribution object for the Gauss hypergeometric distribution using the gausshyper() function:

gausshyper_dist = stats.gausshyper(a, b, c, z)

Here, a, b, c, and z are the shape parameters of the distribution. These parameters should satisfy the condition a, b, c, z > 0.

Methods

The probability distribution object returned by scipy.stats.gausshyper() provides various methods to work with the distribution. Some of the commonly used methods include:

  • pdf(x): Probability density function at value x.
  • cdf(x): Cumulative distribution function at value x.
  • rvs(size): Generate random samples from the distribution.
  • mean(): Mean of the distribution.
  • var(): Variance of the distribution.
  • median(): Median of the distribution.
  • fit(data): Parameter estimation of the distribution.
Example

Here is an example that demonstrates the usage of scipy.stats.gausshyper():

from scipy import stats

# Create a probability distribution object for Gauss hypergeometric distribution
gausshyper_dist = stats.gausshyper(0.5, 1, 1.5, 0.75)

# Generate random samples
samples = gausshyper_dist.rvs(1000)

# Calculate mean and variance
mean = gausshyper_dist.mean()
variance = gausshyper_dist.var()

print("Mean:", mean)
print("Variance:", variance)

In this example, we create a Gauss hypergeometric distribution with shape parameters a = 0.5, b = 1, c = 1.5, and z = 0.75. We then generate 1000 random samples from the distribution and calculate the mean and variance.

Conclusion

The scipy.stats.gausshyper() function in Python provides a flexible way to work with the Gauss hypergeometric distribution. By utilizing the probability distribution object, you can easily perform various statistical calculations and analysis related to this distribution.