# What’s New or Different¶

## Differences from NumPy (1.17+)¶

`UserBitGenerator`

allows bit generators to be written in Python (slow, suitable for experiments and testing) or numba (fast, similar speed to compiled C). See the demonstration notebook for examples.`PCG64`

supports additional variants of PCG64, including the PCG4 2.0 variant (“cm-dxsm”).`SFC64`

supports optional Weyl sequence increments other than 1 which is the fixed increment in`numpy.random.SFC64`

.`random_entropy()`

provides access to the system source of randomness that is used in cryptographic applications (e.g.,`/dev/urandom`

on Unix).Support broadcasting when producing multivariate Gaussian values (

`multivariate_normal()`

)Simulate from the complex normal distribution (

`complex_normal()`

)Direct access to unsigned integers is provided by (

`uintegers()`

)A wider range of bit generators:

Chaotic mappings

Cryptographic Cipher-based:

Hardware-based:

Mersenne Twisters

Permuted Congruential Generators

Shift/rotate based:

Deprecated

`Generator`

is **deprecated**. You should be using
`numpy.random.Generator`

.

randomgen’s

`Generator`

continues to expose legacy methods`random_sample`

,`randint`

,`random_integers`

,`rand`

,`randn`

, and`tomaxint`

.**Note**: These should not be used, and their modern replacements are preferred:`random_sample`

,`rand` → ``random`

`random_integers`

,`randint`

→`integers`

`randn`

→`standard_normal`

`tomaxint`

→`integers`

with`dtype`

set to`int`

randomgen’s bit generators remain seedable and the convenience function

`seed` is exposed as part of``Generator`

. Additionally, the convenience property`state`

is available to get or set the state of the underlying bit generator.`numpy.random.Generator.multivariate_hypergeometric()`

was added after`Generator`

was merged into NumPy and will not be ported over.`numpy.random.Generator.shuffle()`

and`numpy.random.Generator.permutation()`

support`axis`

keyword to operator along an axis other than 0.`integers`

supports the keyword argument`use_masked`

to switch between masked generation of bounded integers and Lemire’s superior method.

## Differences from NumPy before 1.17¶

The normal, exponential and gamma generators use 256-step Ziggurat methods which are 2-10 times faster than NumPy’s default implementation in

`standard_normal`

,`standard_exponential`

or`standard_gamma`

.The Box-Muller used to produce NumPy’s normals is no longer available.

All bit generators functions to produce doubles, uint64s and uint32s via CTypes (

`ctypes()`

) and CFFI (`cffi()`

). This allows the bit generators to be used in numba or in other low-level applicationsThe bit generators can be used in downstream projects via Cython.

Optional

`dtype`

argument that accepts`np.float32`

or`np.float64`

to produce either single or double prevision uniform random variables for select core distributionsUniforms (

`random`

and`rand`

)Normals (

`standard_normal`

and`randn`

)Standard Gammas (

`standard_gamma`

)Standard Exponentials (

`standard_exponential`

)

Optional

`out`

argument that allows existing arrays to be filled for select core distributionsUniforms (

`random`

)Normals (

`standard_normal`

)Standard Gammas (

`standard_gamma`

)Standard Exponentials (

`standard_exponential`

)

This allows multithreading to fill large arrays in chunks using suitable PRNGs in parallel.

`integers`

supports broadcasting inputs.`integers`

supports drawing from open (default,`[low, high)`

) or closed (`[low, high]`

) intervals using the keyword argument`endpoint`

. Closed intervals are simpler to use when the distribution may include the maximum value of a given integer type.The closed interval is particularly helpful when using arrays since it avoids object-dtype arrays when sampling from the full range.

Support for Lemire’s method of generating uniform integers on an arbitrary interval by setting

`use_masked=True`

in (`integers`

).`multinomial`

supports multidimensional values of`n`

`choice`

is much faster when sampling small amounts from large arrays`choice`

supports the`axis`

keyword to work with multidimensional arrays.For changes since the previous release, see the Change Log