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 ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé
Module « scipy.stats.qmc »

Classe « MultinomialQMC »

Informations générales

Héritage

builtins.object
    MultinomialQMC

Définition

class MultinomialQMC(builtins.object):

help(MultinomialQMC)

QMC sampling from a multinomial distribution.

Parameters
----------
pvals : array_like (k,)
    Vector of probabilities of size ``k``, where ``k`` is the number
    of categories. Elements must be non-negative and sum to 1.
n_trials : int
    Number of trials.
engine : QMCEngine, optional
    Quasi-Monte Carlo engine sampler. If None, `Sobol` is used.
rng : `numpy.random.Generator`, optional
    Pseudorandom number generator state. When `rng` is None, a new
    `numpy.random.Generator` is created using entropy from the
    operating system. Types other than `numpy.random.Generator` are
    passed to `numpy.random.default_rng` to instantiate a ``Generator``.

    .. versionchanged:: 1.15.0

        As part of the `SPEC-007 <https://scientific-python.org/specs/spec-0007/>`_
        transition from use of `numpy.random.RandomState` to
        `numpy.random.Generator`, this keyword was changed from `seed` to
        `rng`. For an interim period, both keywords will continue to work, although
        only one may be specified at a time. After the interim period, function
        calls using the `seed` keyword will emit warnings. Following a
        deprecation period, the `seed` keyword will be removed.

Examples
--------
Let's define 3 categories and for a given sample, the sum of the trials
of each category is 8. The number of trials per category is determined
by the `pvals` associated to each category.
Then, we sample this distribution 64 times.

>>> import matplotlib.pyplot as plt
>>> from scipy.stats import qmc
>>> dist = qmc.MultinomialQMC(
...     pvals=[0.2, 0.4, 0.4], n_trials=10, engine=qmc.Halton(d=1)
... )
>>> sample = dist.random(64)

We can plot the sample and verify that the median of number of trials
for each category is following the `pvals`. That would be
``pvals * n_trials = [2, 4, 4]``.

>>> fig, ax = plt.subplots()
>>> ax.yaxis.get_major_locator().set_params(integer=True)
>>> _ = ax.boxplot(sample)
>>> ax.set(xlabel="Categories", ylabel="Trials")
>>> plt.show()

Constructeur(s)

Signature du constructeur Description
__init__(self, pvals: 'npt.ArrayLike', n_trials: int | numpy.integer, *, engine: scipy.stats._qmc.QMCEngine | None = None, rng: int | numpy.integer | numpy.random._generator.Generator | numpy.random.mtrand.RandomState | None = None) -> None

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
random(self, n: int | numpy.integer = 1) -> numpy.ndarray Draw `n` QMC samples from the multinomial distribution. [extrait de random.__doc__]

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

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

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