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-μ|}{λ}),\]Warning
The Ascend backend does not support the reproducibility of random numbers, so the seed parameter has no effect.
- Parameters
shape (tuple) – The shape of random tensor to be generated. The format is \((N,*)\) where \(*\) means, any number of additional dimensions.
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, optional) – 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
GPU
CPU
Examples
>>> import mindspore >>> from mindspore import Tensor >>> from mindspore import ops as ops >>> shape = (2, 3) >>> mean = Tensor(1.0, mindspore.float32) >>> lambda_param = Tensor(1.0, mindspore.float32) >>> output = ops.laplace(shape, mean, lambda_param, seed=5) >>> print(output.shape) (2, 3)