truncated_normal#

class 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 and upper. The default (None) produces a result shape by broadcasting lower and upper.

  • 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 if shape is not None, or else by broadcasting lower and upper. Returns values in the open interval (lower, upper).

Return type:

Array