Probability distribution classes are located in
The methods on continuous distribution classes are as follows.
|Probability density function|
|Cumulative distribution function|
|Survival function = complementary CDF|
|Percentile point function (i.e. CDF inverse)|
|Inverse survival function (Complementary CDF inverse)|
|Mean, variance, skew, or kurtosis|
Functions such as
cdf are defined over the entire real line. For example, the beta distribution is commonly defined on the interval [0, 1]. If you ask for the
cdf to the left of the interval you get 0, and to the right of the interval you get 1.
Distributions have a general form and a “frozen” form. The general form is stateless: you supply the distribution parameters as arguments to every call. The frozen form creates an object with the distribution parameters set. For example, you could evaluate the PDF of a normal(3, 4) distribution at the value 5 by
stats.norm.pdf(5, 3, 4)
mydist = stats.norm(3, 4) mydist.pdf(5)
Note that the argument of the PDF, in this example 5, comes before the distribution parameters. Note also that for discrete distributions, one would call
pmf (probability mass function) rather than the
Distributions and parameterizations
SciPy makes every continuous distribution into a location-scale family, including some distributions that typically do not have location scale parameters. This unusual approach has its advantages. For example, the question of whether an exponential distribtion is parameterized in terms of its mean or its rate goes away: there is no mean or rate parameter per se, only a scale parameter like every other continuous distribution.
The table below only lists parameters in addition to location and scale.
SciPy does not have a simple Weibull distribution but instead has a generalization of the Weibull called the exponentiated Weibull. Set the exponential parameter to 1 and you get the ordinary Weibull distribution.
The hypergeometric distribution gives the probability of various numbers of red balls when N balls are taken from an urn containing n red balls and M–n blue balls. Note that another popular convention uses the number of red and blue balls rather than the number of red balls and the total number of balls.
Note that the parameters for the log-normal are the mean and standard deviation of the log of the distribution, not the mean and standard deviation of the distribution itself.
The PDF or PMF of a distribution is contained in the
extradoc string. For example:
>>> stats.poisson.extradoc Poisson distribution poisson.pmf(k, mu) = exp(-mu) * mu**k / k! for k >= 0
The lognormal distribution as implemented in SciPy may not be the same as the lognormal distribution implemented elsewhere. When the location parameter is 0, the
stats.lognorm with parameter
s corresponds to a lognormal(0, s) distribution as defined here. But if the location parameter is not 0,
stats.lognorm does not correspond to a log-normal distribution under the other distribution. The difference is whether the PDF contains log(x-μ) or log(x) – μ.
For more information, see scipy.stats online documentation.
Need help moving to the Python stack for scientific computing?