mindspore.ops.random_gamma
- mindspore.ops.random_gamma(shape, alpha, seed=None)[source]
Outputs random values from the Gamma distribution(s) described by alpha.
- Parameters
shape (Tensor) – The shape of random tensor to be generated. Must be one of the following types: int32, int64. 1-D integer tensor.
alpha (Tensor) – The \(\alpha\) distribution parameter. A Tensor. Must be one of the following types: half, float32, float64.
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 equal to the concat shape between the input shape and the broadcast of alpha. The dtype is the same type as alpha.
- Raises
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> import mindspore >>> from mindspore import Tensor, ops >>> shape = Tensor(np.array([7, 5]), mindspore.int32) >>> alpha = Tensor(np.array([0.5, 1.5]), mindspore.float32) >>> output = ops.random_gamma(shape, alpha, seed=5) >>> result = output.shape >>> print(result) (7, 5, 2)