mindspore.ops.laplace
- mindspore.ops.laplace(shape, mean, lambda_param, seed=None)[source]
Generates random numbers according to the Laplace random number distribution. It is defined as:
\[\text{f}(x;μ,λ) = \frac{1}{2λ}\exp(-\frac{|x-μ|}{λ}),\]- Parameters
shape (tuple) – The shape of random tensor to be generated.
mean (Tensor) – The mean μ distribution parameter, which specifies the location of the peak. With float32 data type.
lambda_param (Tensor) – The parameter used for controlling the variance of this random distribution. The variance of Laplace distribution is equal to twice the square of lambda_param. With float32 data type.
seed (int) – Seed is used as entropy source for Random number engines generating pseudo-random numbers. Default: None, which will be treated as 0.
- Returns
Tensor. The shape should be the broadcasted shape of Input “shape” and shapes of mean and lambda_param. The dtype is float32.
- Supported Platforms:
Ascend
Examples
>>> from mindspore import Tensor >>> from mindspore.ops import composite as C >>> import mindspore.common.dtype as mstype >>> shape = (2, 3) >>> mean = Tensor(1.0, mstype.float32) >>> lambda_param = Tensor(1.0, mstype.float32) >>> output = C.laplace(shape, mean, lambda_param, seed=5) >>> print(output.shape) (2, 3)