Access to various distributions below is available via Cython or C-wrapper libraries like CFFI. All the functions accept a bitgen_t as their first argument. To access these from Cython or C, you must link with the npyrandom library which is part of the NumPy distribution, located in numpy/random/lib.
bitgen_t
npyrandom
numpy/random/lib
The bitgen_t holds the current state of the BitGenerator and pointers to functions that return standard C types while advancing the state.
struct bitgen: void *state npy_uint64 (*next_uint64)(void *st) nogil uint32_t (*next_uint32)(void *st) nogil double (*next_double)(void *st) nogil npy_uint64 (*next_raw)(void *st) nogil ctypedef bitgen bitgen_t
See Extending for examples of using these functions.
The functions are named with the following conventions:
“standard” refers to the reference values for any parameters. For instance “standard_uniform” means a uniform distribution on the interval 0.0 to 1.0
0.0
1.0
“fill” functions will fill the provided out with cnt values.
out
cnt
The functions without “standard” in their name require additional parameters to describe the distributions.
zig in the name are based on a ziggurat lookup algorithm is used instead of calculating the log, which is significantly faster. The non-ziggurat variants are used in corner cases and for legacy compatibility.
zig
log
random_standard_uniform
random_standard_uniform_fill
random_standard_exponential
random_standard_exponential_fill
random_standard_normal
random_standard_normal_fill
random_standard_normal_fill_f
random_standard_gamma
random_standard_uniform_f
random_standard_uniform_fill_f
random_standard_exponential_f
random_standard_exponential_fill_f
random_standard_normal_f
random_standard_gamma_f
random_normal
random_gamma
random_gamma_f
random_exponential
random_uniform
random_beta
random_chisquare
random_f
random_standard_cauchy
random_pareto
random_weibull
random_power
random_laplace
random_gumbel
random_logistic
random_lognormal
random_rayleigh
random_standard_t
random_noncentral_chisquare
random_noncentral_f
random_wald
random_vonmises
random_triangular
random_poisson
random_negative_binomial
binomial_t
typedef struct s_binomial_t { int has_binomial; /* !=0: following parameters initialized for binomial */ double psave; RAND_INT_TYPE nsave; double r; double q; double fm; RAND_INT_TYPE m; double p1; double xm; double xl; double xr; double c; double laml; double lamr; double p2; double p3; double p4; } binomial_t;
random_binomial
random_logseries
random_geometric_search
random_geometric_inversion
random_geometric
random_zipf
random_hypergeometric
random_interval
random_multinomial
random_multivariate_hypergeometric_count
random_multivariate_hypergeometric_marginals
Generate a single integer
random_positive_int64
random_positive_int32
random_positive_int
random_uint
Generate random uint64 numbers in closed interval [off, off + rng].
random_bounded_uint64