brainpy.math.random.RandomState#
- class brainpy.math.random.RandomState(seed_or_key=None, seed=None)[source]#
RandomState that track the random generator state.
- __init__(seed_or_key=None, seed=None)[source]#
RandomState constructor.
- Parameters:
seed_or_key (int, Array, optional) –
It can be an integer for initial seed of the random number generator, or it can be a JAX’s PRNKey, which is an array with two elements and uint32 dtype.
New in version 2.2.3.4.
seed (int, ArrayType, optional) –
Same as seed_or_key.
Deprecated since version 2.2.3.4: Will be removed since version 2.4.
Methods
__init__
([seed_or_key, seed])RandomState constructor.
abs
(*[, out])- rtype:
Optional
[Array
]
abs_
()in-place version of Array.abs()
absolute
(*[, out])alias of Array.abs
absolute_
()alias of Array.abs_()
addr
(vec1, vec2, *[, beta, alpha, out])Performs the outer-product of vectors
vec1
andvec2
and adds it to the matrixinput
.addr_
(vec1, vec2, *[, beta, alpha])- rtype:
all
([axis, keepdims])Returns True if all elements evaluate to True.
any
([axis, keepdims])Returns True if any of the elements of a evaluate to True.
arccos
(*[, out])- rtype:
Optional
[Array
]
arccos_
()- rtype:
arcsin
(*[, out])- rtype:
Optional
[Array
]
arcsin_
()- rtype:
arctan
(*[, out])- rtype:
Optional
[Array
]
arctan_
()- rtype:
argmax
([axis])Return indices of the maximum values along the given axis.
argmin
([axis])Return indices of the minimum values along the given axis.
argpartition
(kth[, axis, kind, order])Returns the indices that would partition this array.
argsort
([axis, kind, order])Returns the indices that would sort this array.
as_variable
()As an instance of Variable.
astype
(dtype)Copy of the array, cast to a specified type.
bernoulli
(p[, size, key])Sample Bernoulli random values with given shape and mean.
beta
(a, b[, size, key])Draw samples from a Beta distribution.
binomial
(n, p[, size, key])block_host_until_ready
(*args)block_until_ready
(*args)byteswap
([inplace])Swap the bytes of the array elements
categorical
(logits[, axis, size, key])Sample random values from categorical distributions.
chisquare
(df[, size, key])choice
(a[, size, replace, p, key])Generates a random sample from a given 1-D array
choose
(choices[, mode])Use an index array to construct a new array from a set of choices.
clamp
([min_value, max_value, out])return the value between min_value and max_value, if min_value is None, then no lower bound, if max_value is None, then no upper bound.
clamp_
([min_value, max_value])return the value between min_value and max_value, if min_value is None, then no lower bound, if max_value is None, then no upper bound.
clip
([min, max, out])Return an array whose values are limited to [min, max].
clip_
([min_value, max_value])alias for clamp_
clone
()compress
(condition[, axis])Return selected slices of this array along given axis.
conj
()Complex-conjugate all elements.
conjugate
()Return the complex conjugate, element-wise.
copy
()Return a copy of the array.
copy_
(src)- rtype:
cos
(*[, out])- rtype:
Optional
[Array
]
cos_
()- rtype:
cosh
(*[, out])- rtype:
Optional
[Array
]
cosh_
()- rtype:
cov_with
([y, rowvar, bias, ddof, fweights, ...])- rtype:
Array
cumprod
([axis, dtype])Return the cumulative product of the elements along the given axis.
cumsum
([axis, dtype])Return the cumulative sum of the elements along the given axis.
device
()diagonal
([offset, axis1, axis2])Return specified diagonals.
dirichlet
(alpha[, size, key])dot
(b)Dot product of two arrays.
expand
(*sizes)Expand an array to a new shape.
expand_as
(array)Expand an array to a shape of another array.
expand_dims
(axis)exponential
([scale, size, key])f
(dfnum, dfden[, size, key])fill
(value)Fill the array with a scalar value.
flatten
()gamma
(shape[, scale, size, key])geometric
(p[, size, key])gumbel
([loc, scale, size, key])hypergeometric
(ngood, nbad, nsample[, size, key])item
(*args)Copy an element of an array to a standard Python scalar and return it.
laplace
([loc, scale, size, key])loggamma
(a[, size, key])Sample log-gamma random values.
logistic
([loc, scale, size, key])lognormal
([mean, sigma, size, key])logseries
(p[, size, key])max
([axis, keepdims])Return the maximum along a given axis.
maxwell
([size, key])Sample from a one sided Maxwell distribution.
mean
([axis, dtype, keepdims])Returns the average of the array elements along given axis.
min
([axis, keepdims])Return the minimum along a given axis.
multinomial
(n, pvals[, size, key])multivariate_normal
(mean, cov[, size, ...])negative_binomial
(n, p[, size, key])noncentral_chisquare
(df, nonc[, size, key])noncentral_f
(dfnum, dfden, nonc[, size, key])nonzero
()Return the indices of the elements that are non-zero.
normal
([loc, scale, size, key])numpy
([dtype])Convert to numpy.ndarray.
orthogonal
(n[, size, key])Sample uniformly from the orthogonal group O(n).
outer
(other)- rtype:
Array
pareto
(a[, size, key])permutation
(x[, axis, independent, key])Randomly permute a sequence, or return a permuted range.
poisson
([lam, size, key])pow
(index)power
(a[, size, key])prod
([axis, dtype, keepdims, initial, where])Return the product of the array elements over the given axis.
ptp
([axis, keepdims])Peak to peak (maximum - minimum) value along a given axis.
put
(indices, values)Replaces specified elements of an array with given values.
rand
(*dn[, key])Random values in a given shape.
rand_like
(input, *[, dtype, key])Returns a tensor with the same size as input that is filled with random numbers from a uniform distribution on the interval
[0, 1)
.randint
(low[, high, size, dtype, key])Return random integers from low (inclusive) to high (exclusive).
randint_like
(input[, low, high, dtype, key])Similar to
randint_like
in torch.randn
(*dn[, key])Return a sample (or samples) from the "standard normal" distribution.
randn_like
(input, *[, dtype, key])Returns a tensor with the same size as
input
that is filled with random numbers from a normal distribution with mean 0 and variance 1.random
([size, key])Return random floats in the half-open interval [0.0, 1.0).
random_integers
(low[, high, size, key])Random integers of type np.int_ between low and high, inclusive.
random_sample
([size, key])Return random floats in the half-open interval [0.0, 1.0).
ranf
([size, key])This is an alias of random_sample. See random_sample for the complete
ravel
([order])Return a flattened array.
rayleigh
([scale, size, key])repeat
(repeats[, axis])Repeat elements of an array.
reshape
(*shape[, order])Returns an array containing the same data with a new shape.
resize
(new_shape)Change shape and size of array in-place.
round
([decimals])Return
a
with each element rounded to the given number of decimals.sample
([size, key])This is an alias of random_sample. See random_sample for the complete
searchsorted
(v[, side, sorter])Find indices where elements should be inserted to maintain order.
seed
([seed_or_key, seed])Sets a new random seed.
shuffle
(x[, axis, key])Modify a sequence in-place by shuffling its contents.
sin
(*[, out])- rtype:
Optional
[Array
]
sin_
()- rtype:
sinh
(*[, out])- rtype:
Optional
[Array
]
sinh_
()- rtype:
sort
([axis, kind, order])Sort an array in-place.
split
(indices_or_sections[, axis])Split an array into multiple sub-arrays as views into
ary
.split_key
()Create a new seed from the current seed.
split_keys
(n)Create multiple seeds from the current seed.
squeeze
([axis])Remove axes of length one from
a
.standard_cauchy
([size, key])standard_exponential
([size, key])standard_gamma
(shape[, size, key])standard_normal
([size, key])standard_t
(df[, size, key])std
([axis, dtype, ddof, keepdims])Compute the standard deviation along the specified axis.
sum
([axis, dtype, keepdims, initial, where])Return the sum of the array elements over the given axis.
swapaxes
(axis1, axis2)Return a view of the array with axis1 and axis2 interchanged.
t
(df[, size, key])Sample Student’s t random values.
take
(indices[, axis, mode])Return an array formed from the elements of a at the given indices.
tan
(*[, out])- rtype:
Optional
[Array
]
tan_
()- rtype:
tanh
(*[, out])- rtype:
Optional
[Array
]
tanh_
()- rtype:
tile
(reps)Construct an array by repeating A the number of times given by reps.
to_jax
([dtype])Convert to jax.numpy.ndarray.
to_numpy
([dtype])Convert to numpy.ndarray.
tobytes
()Construct Python bytes containing the raw data bytes in the array.
tolist
()Return the array as an
a.ndim
-levels deep nested list of Python scalars.trace
([offset, axis1, axis2, dtype])Return the sum along diagonals of the array.
transpose
(*axes)Returns a view of the array with axes transposed.
triangular
([size, key])truncated_normal
(lower, upper[, size, ...])Sample truncated standard normal random values with given shape and dtype.
uniform
([low, high, size, key])unsqueeze
(dim)equals Array.expand_dims(dim)
update
(value)Update the value of this Array.
var
([axis, dtype, ddof, keepdims])Returns the variance of the array elements, along given axis.
view
(*args[, dtype])New view of array with the same data.
vonmises
(mu, kappa[, size, key])wald
(mean, scale[, size, key])weibull
(a[, size, key])Draw samples from a Weibull distribution.
weibull_min
(a[, scale, size, key])Sample from a Weibull minimum distribution.
zipf
(a[, size, key])Draw samples from a Zipf distribution.
Attributes
T
at
batch_axis
batch_size
device_buffer
dtype
Variable dtype.
imag
is_brainpy_array
ndim
nobatch_shape
Shape without batch axis.
real
shape
Variable shape.
size
value