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 ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Module « scipy.stats.qmc »

Classe « Halton »

Informations générales

Héritage

builtins.object
    ABC
        QMCEngine
            Halton

Définition

class Halton(QMCEngine):

help(Halton)

Halton sequence.

Pseudo-random number generator that generalize the Van der Corput sequence
for multiple dimensions. The Halton sequence uses the base-two Van der
Corput sequence for the first dimension, base-three for its second and
base-:math:`n` for its n-dimension.

Parameters
----------
d : int
    Dimension of the parameter space.
scramble : bool, optional
    If True, use Owen scrambling. Otherwise no scrambling is done.
    Default is True.
optimization : {None, "random-cd", "lloyd"}, optional
    Whether to use an optimization scheme to improve the quality after
    sampling. Note that this is a post-processing step that does not
    guarantee that all properties of the sample will be conserved.
    Default is None.

    * ``random-cd``: random permutations of coordinates to lower the
      centered discrepancy. The best sample based on the centered
      discrepancy is constantly updated. Centered discrepancy-based
      sampling shows better space-filling robustness toward 2D and 3D
      subprojections compared to using other discrepancy measures.
    * ``lloyd``: Perturb samples using a modified Lloyd-Max algorithm.
      The process converges to equally spaced samples.

    .. versionadded:: 1.10.0

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.

Notes
-----
The Halton sequence has severe striping artifacts for even modestly
large dimensions. These can be ameliorated by scrambling. Scrambling
also supports replication-based error estimates and extends
applicability to unbounded integrands.

References
----------
.. [1] Halton, "On the efficiency of certain quasi-random sequences of
   points in evaluating multi-dimensional integrals", Numerische
   Mathematik, 1960.
.. [2] A. B. Owen. "A randomized Halton algorithm in R",
   :arxiv:`1706.02808`, 2017.

Examples
--------
Generate samples from a low discrepancy sequence of Halton.

>>> from scipy.stats import qmc
>>> sampler = qmc.Halton(d=2, scramble=False)
>>> sample = sampler.random(n=5)
>>> sample
array([[0.        , 0.        ],
       [0.5       , 0.33333333],
       [0.25      , 0.66666667],
       [0.75      , 0.11111111],
       [0.125     , 0.44444444]])

Compute the quality of the sample using the discrepancy criterion.

>>> qmc.discrepancy(sample)
0.088893711419753

If some wants to continue an existing design, extra points can be obtained
by calling again `random`. Alternatively, you can skip some points like:

>>> _ = sampler.fast_forward(5)
>>> sample_continued = sampler.random(n=5)
>>> sample_continued
array([[0.3125    , 0.37037037],
       [0.8125    , 0.7037037 ],
       [0.1875    , 0.14814815],
       [0.6875    , 0.48148148],
       [0.4375    , 0.81481481]])

Finally, samples can be scaled to bounds.

>>> l_bounds = [0, 2]
>>> u_bounds = [10, 5]
>>> qmc.scale(sample_continued, l_bounds, u_bounds)
array([[3.125     , 3.11111111],
       [8.125     , 4.11111111],
       [1.875     , 2.44444444],
       [6.875     , 3.44444444],
       [4.375     , 4.44444444]])

Constructeur(s)

Signature du constructeur Description
__init__(self, d: int | numpy.integer, *, scramble: bool = True, optimization: Optional[Literal['random-cd', 'lloyd']] = 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

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

__init_subclass__, __subclasshook__, fast_forward, integers, random, reset

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

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

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