dpnp.random.Generator.triangular

method

Generator.triangular(left, mode, right, size=None, dtype=None, *, usm_type=None)[source]

Draw samples from the triangular distribution over the interval [left, right].

For full documentation refer to numpy.random.Generator.triangular.

Parameters:
left{float, array_like of floats, dpnp.ndarray, usm_ndarray}

The lower limit of the distribution.

mode{float, array_like of floats, dpnp.ndarray, usm_ndarray}

The value where the peak of the distribution occurs, with left <= mode <= right.

right{float, array_like of floats, dpnp.ndarray, usm_ndarray}

The upper limit of the distribution, greater than left.

size{None, int, tuple of ints}, optional

Output shape. With None, the broadcast shape of left, mode and right.

Default: None.

dtype{None, dtype}, optional

The data type of the output, dpnp.float32 or dpnp.float64.

Default: None, which means the default floating-point type of the device.

usm_type{None, "device", "shared", "host"}, optional

The type of SYCL USM allocation for the output array.

Default: None, which means the USM type of the array parameters, or "device" when there are none.

Returns:
outdpnp.ndarray

The samples.

Limitations

dtype and usm_type are not in NumPy's signature.

Examples

>>> import dpnp as np
>>> rng = np.random.default_rng(42)
>>> x = rng.triangular(-1.0, 0.0, 2.0, 10**5)
>>> a = bool(((-1 <= x) & (x <= 2)).all())
>>> b = bool(abs(x.mean() - 1 / 3) < 0.015)
>>> a, b
(True, True)