brainpy.math.random.truncated_normal#
- brainpy.math.random.truncated_normal(lower, upper, size=None, scale=None, key=None)[source]#
Sample truncated standard normal random values with given shape and dtype.
- Parameters:
lower (float, ndarray) – A float or array of floats representing the lower bound for truncation. Must be broadcast-compatible with
upper
.upper (float, ndarray) – A float or array of floats representing the upper bound for truncation. Must be broadcast-compatible with
lower
.size (optional, list of int, tuple of int) – A tuple of nonnegative integers specifying the result shape. Must be broadcast-compatible with
lower
andupper
. The default (None) produces a result shape by broadcastinglower
andupper
.scale (float, ndarray) – Standard deviation (spread or “width”) of the distribution. Must be non-negative.
- Returns:
out – A random array with the specified dtype and shape given by
shape
ifshape
is not None, or else by broadcastinglower
andupper
. Returns values in the open interval(lower, upper)
.- Return type:
Array