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 »

Fonction order_statistic - module scipy.stats

Signature de la fonction order_statistic

def order_statistic(X, /, *, r, n) 

Description

help(scipy.stats.order_statistic)

Probability distribution of an order statistic

Returns a random variable that follows the distribution underlying the
:math:`r^{\text{th}}` order statistic of a sample of :math:`n`
observations of a random variable :math:`X`.

Parameters
----------
X : `ContinuousDistribution`
    The random variable :math:`X`
r : array_like
    The (positive integer) rank of the order statistic :math:`r`
n : array_like
    The (positive integer) sample size :math:`n`

Returns
-------
Y : `ContinuousDistribution`
    A random variable that follows the distribution of the prescribed
    order statistic.

Notes
-----
If we make :math:`n` observations of a continuous random variable
:math:`X` and sort them in increasing order
:math:`X_{(1)}, \dots, X_{(r)}, \dots, X_{(n)}`,
:math:`X_{(r)}` is known as the :math:`r^{\text{th}}` order statistic.

If the PDF, CDF, and CCDF underlying math:`X` are denoted :math:`f`,
:math:`F`, and :math:`F'`, respectively, then the PDF underlying
math:`X_{(r)}` is given by:

.. math::

    f_r(x) = \frac{n!}{(r-1)! (n-r)!} f(x) F(x)^{r-1} F'(x)^{n - r}

The CDF and other methods of the distribution underlying :math:`X_{(r)}`
are calculated using the fact that :math:`X = F^{-1}(U)`, where :math:`U` is
a standard uniform random variable, and that the order statistics of
observations of `U` follow a beta distribution, :math:`B(r, n - r + 1)`.

References
----------
.. [1] Order statistic. *Wikipedia*. https://en.wikipedia.org/wiki/Order_statistic

Examples
--------
Suppose we are interested in order statistics of samples of size five drawn
from the standard normal distribution. Plot the PDF underlying each
order statistic and compare with a normalized histogram from simulation.

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import stats
>>>
>>> X = stats.Normal()
>>> data = X.sample(shape=(10000, 5))
>>> sorted = np.sort(data, axis=1)
>>> Y = stats.order_statistic(X, r=[1, 2, 3, 4, 5], n=5)
>>>
>>> ax = plt.gca()
>>> colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
>>> for i in range(5):
...     y = sorted[:, i]
...     ax.hist(y, density=True, bins=30, alpha=0.1, color=colors[i])
>>> Y.plot(ax=ax)
>>> plt.show()



Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé