cratermaker.utils.montecarlo_utils.bounded_norm#
- cratermaker.utils.montecarlo_utils.bounded_norm(loc, scale, size=1, lower_bound=None, upper_bound=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#
Sample from a truncated normal distribution that is bounded by either an upper and lower bound, or if None is provided, by the 1-sigma stdev.
- Parameters:
loc (FloatLike) – mean of the distribution
scale (FloatLike) – standard deviation and bounds of the distribution
size (int or tuple of ints, optional) – The number of samples to generate. If the shape is (m, n, k), then m * n * k samples are drawn. If size is None (the default), a single value is returned if diameters is a scalar, otherwise an array of samples is returned with the same size as diameters.
lower_bound (FloatLike | None, optional) – The lower bound of the distribution. If None, the lower bound is set to mean - scale.
upper_bound (FloatLike | None, optional) – The upper bound of the distribution. If None, the upper bound is set to mean + scale.
rng (numpy.random.Generator | None) – A numpy random number generator. If None, a new generator is created using the rng_seed if it is provided.
rng_seed (Any type allowed by the rng_seed argument of numpy.random.Generator, optional) – The rng_seed for the RNG. If None, a new RNG is created.
rng_state (dict, optional) – The state of the random number generator. If None, a new state is created.
**kwargs (Any)
- Returns:
float – Truncated norm bounded by loc-scale, loc+scale