Jump to content

Python: Difference between revisions

249 bytes added ,  7 January 2021
Line 429: Line 429:


==Numpy==
==Numpy==
{{main | NumPy}}
See also Cupy which is a numpy interface implemented with CUDA for GPU acceleration. Large speedups can be had for big arrays.
===random===
===random===
Legacy code uses functions from <code>np.random.</code>.
Legacy code uses functions from <code>np.random.*</code>.


New could should initialize a rng using <code>np.random.default_rng()</code>.
New code should initialize a rng using <code>np.random.default_rng()</code>
See [https://numpy.org/doc/stable/reference/random/generator.html Random Generator] for more details.


<syntaxhighlight lang="python">
<syntaxhighlight lang="python">