Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « scipy.stats »

Classe « Uniform »

Informations générales

Héritage

builtins.object
    ABC
        _ProbabilityDistribution
            ContinuousDistribution
                Uniform

Définition

class Uniform(ContinuousDistribution):

help(Uniform)

Uniform distribution.

The probability density function of the uniform distribution is:

.. math::

    f(x; a, b) = \frac{1}
                      {b - a}

for :math:`x` in [a, b].
This class accepts one parameterization:
`a` for :math:`a \in (-\infty, \infty)`, `b` for :math:`b \in (a, \infty)`.


Parameters
----------
tol : positive float, optional
    The desired relative tolerance of calculations. Left unspecified,
    calculations may be faster; when provided, calculations may be
    more likely to meet the desired accuracy.
validation_policy : {None, "skip_all"}
    Specifies the level of input validation to perform. Left unspecified,
    input validation is performed to ensure appropriate behavior in edge
    case (e.g. parameters out of domain, argument outside of distribution
    support, etc.) and improve consistency of output dtype, shape, etc.
    Pass ``'skip_all'`` to avoid the computational overhead of these
    checks when rough edges are acceptable.
cache_policy : {None, "no_cache"}
    Specifies the extent to which intermediate results are cached. Left
    unspecified, intermediate results of some calculations (e.g. distribution
    support, moments, etc.) are cached to improve performance of future
    calculations. Pass ``'no_cache'`` to reduce memory reserved by the class
    instance.

Attributes
----------
All parameters are available as attributes.

Methods
-------
support
plot
sample
moment
mean
median
mode
variance
standard_deviation
skewness
kurtosis
pdf
logpdf
cdf
icdf
ccdf
iccdf
logcdf
ilogcdf
logccdf
ilogccdf
entropy
logentropy

See Also
--------

:ref:`rv_infrastructure`
    Tutorial


Notes
-----
The following abbreviations are used throughout the documentation.

- PDF: probability density function
- CDF: cumulative distribution function
- CCDF: complementary CDF
- entropy: differential entropy
- log-*F*: logarithm of *F* (e.g. log-CDF)
- inverse *F*: inverse function of *F* (e.g. inverse CDF)

The API documentation is written to describe the API, not to serve as
a statistical reference. Effort is made to be correct at the level
required to use the functionality, not to be mathematically rigorous.
For example, continuity and differentiability may be implicitly assumed.
For precise mathematical definitions, consult your preferred mathematical
text.

Examples
--------
To use the distribution class, it must be instantiated using keyword
parameters corresponding with one of the accepted parameterizations.

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import stats
>>> from scipy.stats import Uniform
>>> X = Uniform(a=0.09, b=188.73)

For convenience, the ``plot`` method can be used to visualize the density
and other functions of the distribution.

>>> X.plot()
>>> plt.show()

The support of the underlying distribution is available using the ``support``
method.

>>> X.support()
(np.float64(0.09), np.float64(188.73))

The numerical values of parameters associated with all parameterizations
are available as attributes.

>>> X.a, X.b, X.ab
(np.float64(0.09), np.float64(188.73), np.float64(188.64))

To evaluate the probability density function of the underlying distribution
at argument ``x=60.45``:

>>> x = 60.45
>>> X.pdf(x)
0.005301102629346905

The cumulative distribution function, its complement, and the logarithm
of these functions are evaluated similarly.

>>> np.allclose(np.exp(X.logccdf(x)), 1 - X.cdf(x))
True

The inverse of these functions with respect to the argument ``x`` is also
available.

>>> logp = np.log(1 - X.ccdf(x))
>>> np.allclose(X.ilogcdf(logp), x)
True

Note that distribution functions and their logarithms also have two-argument
versions for working with the probability mass between two arguments. The
result tends to be more accurate than the naive implementation because it avoids
subtractive cancellation.

>>> y = 120.82
>>> np.allclose(X.ccdf(x, y), 1 - (X.cdf(y) - X.cdf(x)))
True

There are methods for computing measures of central tendency,
dispersion, higher moments, and entropy.

>>> X.mean(), X.median(), X.mode()
(np.float64(94.41), np.float64(94.41), np.float64(94.41))
>>> X.variance(), X.standard_deviation()
(np.float64(2965.4208), np.float64(54.4556773899655))
>>> X.skewness(), X.kurtosis()
(np.float64(1.4418186690070737e-15), np.float64(1.7999999999999878))
>>> np.allclose(X.moment(order=6, kind='standardized'),
...             X.moment(order=6, kind='central') / X.variance()**3)
True
>>> np.allclose(np.exp(X.logentropy()), X.entropy())
True

Pseudo-random samples can be drawn from
the underlying distribution using ``sample``.

>>> X.sample(shape=(4,))
array([ 93.18139471, 155.32221409, 176.91098179, 162.07433859])  # may vary

Constructeur(s)

Signature du constructeur Description
__init__(self, *, a=None, b=None, **kwargs)

Liste des propriétés

Nom de la propriétéDescription
a
ab
b
cache_policy{None, "no_cache"}: [extrait de cache_policy.__doc__]
tolpositive float: [extrait de tol.__doc__]
validation_policy{None, "skip_all"}: [extrait de validation_policy.__doc__]

Liste des opérateurs

Opérateurs hérités de la classe ContinuousDistribution

__add__, __mul__, __neg__, __pow__, __radd__, __rmul__, __rpow__, __rsub__, __rtruediv__, __sub__, __truediv__

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription

Méthodes héritées de la classe ContinuousDistribution

__abs__, __init_subclass__, __repr__, __str__, __subclasshook__, ccdf, cdf, entropy, iccdf, icdf, ilogccdf, ilogcdf, kurtosis, logccdf, logcdf, logentropy, logpdf, mean, median, mode, moment, pdf, plot, reset_cache, sample, skewness, standard_deviation, support, variance

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé