📅  最后修改于: 2023-12-03 15:05:05.580000             🧑  作者: Mango
scipy.stats.gompertz()
is a statistical method in Python's SciPy library that represents the Gompertz (or truncated Gumbel) distribution. This function is used to generate probability distributions of continuous random variables.
scipy.stats.gompertz(c, loc=0, scale=1)
Here, the parameters are:
c
: The shape parameter of the Gompertz distribution. This parameter must be greater than zero.loc
: The location parameter that shifts the distribution to the left or right on the x-axis. Default value is 0.scale
: The scale parameter that determines the spread of the distribution. Default value is 1.from scipy.stats import gompertz
import matplotlib.pyplot as plt
c = 0.5
loc = 0
scale = 0.8
rv = gompertz(c, loc, scale)
x = np.linspace(0, 10)
plt.plot(x, rv.pdf(x), 'k-', lw=2, label='Gompertz PDF')
plt.legend()
plt.show()
This code generates a Gompertz probability distribution with shape parameter c=0.5
, location parameter loc=0
and scale parameter scale=0.8
. The probability density function (PDF) is then plotted using Matplotlib.
The above code will generate the following figure:
This figure shows a typical Gompertz probability distribution with a right-skewed shape. The peak of the distribution is located towards the right of the x-axis, indicating a higher probability of larger values in the distribution.
In conclusion, scipy.stats.gompertz()
is a useful function in the SciPy library that can be used to generate Gompertz probability distributions. The flexibility of the function allows for easy modification of the shape, location, and scale parameters to produce different types of distributions.