If seed
is not a BitGenerator
or a Generator
, a new BitGenerator
is instantiated. This function does not manage a default global instance.
A seed to initialize the BitGenerator
. If None, then fresh, unpredictable entropy will be pulled from the OS. If an int
or array_like[ints]
is passed, then it will be passed to SeedSequence
to derive the initial BitGenerator
state. One may also pass in a SeedSequence
instance. Additionally, when passed a BitGenerator
, it will be wrapped by Generator
. If passed a Generator
, it will be returned unaltered.
The initialized generator object.
Construct a new Generator with the default BitGenerator (PCG64).
default_rng
is the recommended constructor for the random number class Generator
. Here are several ways we can construct a random number generator using default_rng
and the Generator
class.
Here we use default_rng
to generate a random float:
>>> import numpy as np
... rng = np.random.default_rng(12345)
... print(rng) Generator(PCG64)
>>> rfloat = rng.random()
... rfloat 0.22733602246716966
>>> type(rfloat) <class 'float'>
Here we use default_rng
to generate 3 random integers between 0 (inclusive) and 10 (exclusive):
>>> import numpy as np
... rng = np.random.default_rng(12345)
... rints = rng.integers(low=0, high=10, size=3)
... rints array([6, 2, 7])
>>> type(rints[0]) <class 'numpy.int64'>
Here we specify a seed so that we have reproducible results:
>>> import numpy as np
... rng = np.random.default_rng(seed=42)
... print(rng) Generator(PCG64)
>>> arr1 = rng.random((3, 3))
... arr1 array([[0.77395605, 0.43887844, 0.85859792], [0.69736803, 0.09417735, 0.97562235], [0.7611397 , 0.78606431, 0.12811363]])
If we exit and restart our Python interpreter, we'll see that we generate the same random numbers again:
>>> import numpy as npSee :
... rng = np.random.default_rng(seed=42)
... arr2 = rng.random((3, 3))
... arr2 array([[0.77395605, 0.43887844, 0.85859792], [0.69736803, 0.09417735, 0.97562235], [0.7611397 , 0.78606431, 0.12811363]])
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.linalg.blas.find_best_blas_typescipy.fft._pocketfft.helper.set_workersscipy.spatial._kdtree.KDTree.count_neighborsscipy.sparse.linalg._eigen.lobpcg.lobpcg.lobpcgscipy.linalg._decomp_qr.qrscipy.linalg._basic.pinvscipy.optimize._optimize.check_gradscipy.linalg._decomp_svd.subspace_anglesscipy.signal._signaltools.correlate2dscipy.signal._signaltools.wienerscipy.signal._spectral_py.periodogramscipy.spatial._qhull.ConvexHullscipy.linalg._decomp_svd.svdscipy.optimize._zeros_py.newtonscipy.signal._bsplines.qspline1dscipy.fft._realtransforms.dctnscipy.fft._realtransforms.idctnscipy.spatial._kdtree.KDTree.query_ball_treescipy.signal._bsplines.cspline1d_evalscipy.interpolate._polyint.KroghInterpolatorscipy.optimize._basinhopping.basinhoppingscipy.interpolate._bsplines.make_lsq_splinescipy.interpolate._ndgriddata.NearestNDInterpolatorscipy.spatial._qhull.tsearchscipy.linalg.lapack.get_lapack_funcsscipy.fft._helper.next_fast_lenscipy.linalg._expm_frechet.expm_frechetscipy.interpolate._rbf.Rbfscipy.signal._signaltools.filtfiltscipy.signal._signaltools.fftconvolvescipy.fft._basic.ifftscipy.signal._spectral_py.lombscarglescipy.interpolate._fitpack2.LSQUnivariateSplinescipy.signal._filter_design.freqzscipy.interpolate._fitpack2.UnivariateSplinescipy.signal._signaltools.choose_conv_methodscipy.sparse.linalg._eigen._svds.svdsscipy.signal._spectral_py.coherencescipy.signal._signaltools.sosfiltfiltscipy.sparse._construct.randomscipy.linalg._decomp_svd.null_spacescipy.signal._spectral_py.stftscipy.linalg._basic.pinvhscipy.signal._bsplines.qspline1d_evalscipy.signal._signaltools.correlation_lagsscipy.signal._signaltools.lfilterscipy.signal._spectral_py.csdscipy.interpolate._ndgriddata.griddatascipy.linalg.blas.get_blas_funcsscipy.fft._basic.ifftnscipy.fft._basic.fftnscipy.spatial._plotutils.voronoi_plot_2dscipy.fft._realtransforms.idstnscipy.signal._signaltools.detrendscipy.signal._bsplines.cspline1dscipy.spatial._kdtree.KDTree.query_pairsscipy.signal._signaltools.correlatescipy.signal._spectral_py.welchscipy.spatial._plotutils.convex_hull_plot_2dscipy.fft._realtransforms.dstnscipy.spatial._plotutils.delaunay_plot_2dscipy.spatial._kdtree.KDTree.sparse_distance_matrixscipy.linalg._decomp_qz.qzscipy.interpolate._fitpack2.InterpolatedUnivariateSplinescipy.linalg._decomp_qr.rqscipy.signal._spectral_py.spectrogramscipy.interpolate.interpnd.LinearNDInterpolatorscipy.interpolate._rbfinterp.RBFInterpolatorscipy.signal._spectral_py.istftscipy.optimize._minpack_py.curve_fitscipy.signal._signaltools.oaconvolveHover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them