package np

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Generator
]
type t = [ `Generator | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : Py.Object.t -> t

Generator(bit_generator)

Container for the BitGenerators.

``Generator`` exposes a number of methods for generating random numbers drawn from a variety of probability distributions. In addition to the distribution-specific arguments, each method takes a keyword argument `size` that defaults to ``None``. If `size` is ``None``, then a single value is generated and returned. If `size` is an integer, then a 1-D array filled with generated values is returned. If `size` is a tuple, then an array with that shape is filled and returned.

The function :func:`numpy.random.default_rng` will instantiate a `Generator` with numpy's default `BitGenerator`.

**No Compatibility Guarantee**

``Generator`` does not provide a version compatibility guarantee. In particular, as better algorithms evolve the bit stream may change.

Parameters ---------- bit_generator : BitGenerator BitGenerator to use as the core generator.

Notes ----- The Python stdlib module `random` contains pseudo-random number generator with a number of methods that are similar to the ones available in ``Generator``. It uses Mersenne Twister, and this bit generator can be accessed using ``MT19937``. ``Generator``, besides being NumPy-aware, has the advantage that it provides a much larger number of probability distributions to choose from.

Examples -------- >>> from numpy.random import Generator, PCG64 >>> rg = Generator(PCG64()) >>> rg.standard_normal() -0.203 # random

See Also -------- default_rng : Recommended constructor for `Generator`.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.