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 ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé
Module « scipy.stats »

Fonction make_distribution - module scipy.stats

Signature de la fonction make_distribution

def make_distribution(dist) 

Description

help(scipy.stats.make_distribution)

Generate a `ContinuousDistribution` from an instance of `rv_continuous`

The returned value is a `ContinuousDistribution` subclass. Like any subclass
of `ContinuousDistribution`, it must be instantiated (i.e. by passing all shape
parameters as keyword arguments) before use. Once instantiated, the resulting
object will have the same interface as any other instance of
`ContinuousDistribution`; e.g., `scipy.stats.Normal`.

.. note::

    `make_distribution` does not work perfectly with all instances of
    `rv_continuous`. Known failures include `levy_stable` and `vonmises`,
    and some methods of some distributions will not support array shape
    parameters.

Parameters
----------
dist : `rv_continuous`
    Instance of `rv_continuous`.

Returns
-------
CustomDistribution : `ContinuousDistribution`
    A subclass of `ContinuousDistribution` corresponding with `dist`. The
    initializer requires all shape parameters to be passed as keyword arguments
    (using the same names as the instance of `rv_continuous`).

Notes
-----
The documentation of `ContinuousDistribution` is not rendered. See below for
an example of how to instantiate the class (i.e. pass all shape parameters of
`dist` to the initializer as keyword arguments). Documentation of all methods
is identical to that of `scipy.stats.Normal`. Use ``help`` on the returned
class or its methods for more information.

Examples
--------
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import stats
>>> LogU = stats.make_distribution(stats.loguniform)
>>> X = LogU(a=1.0, b=3.0)
>>> np.isclose((X + 0.25).median(), stats.loguniform.ppf(0.5, 1, 3, loc=0.25))
np.True_
>>> X.plot()
>>> sample = X.sample(10000, rng=np.random.default_rng())
>>> plt.hist(sample, density=True, bins=30)
>>> plt.legend(('pdf', 'histogram'))
>>> plt.show()



Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé