r"""Random variable with Gaussian distribution :math:`N(\mu, \sigma)`. Args: mean(float): the mean or expectation of the distribution. Default: 0. std(float): the standard deviation of the distribution (variance = :math:`\sigma ^ 2`). Default: 1.
(
self, mean: float = 0, std: float = 1, size: Optional[Iterable[int]] = None
)
| 343 | ) |
| 344 | |
| 345 | def normal( |
| 346 | self, mean: float = 0, std: float = 1, size: Optional[Iterable[int]] = None |
| 347 | ): |
| 348 | r"""Random variable with Gaussian distribution :math:`N(\mu, \sigma)`. |
| 349 | |
| 350 | Args: |
| 351 | mean(float): the mean or expectation of the distribution. Default: 0. |
| 352 | std(float): the standard deviation of the distribution (variance = :math:`\sigma ^ 2`). |
| 353 | Default: 1. |
| 354 | size(Optional[Iterable[int]]): the size of output tensor. Default: None. |
| 355 | |
| 356 | Returns: |
| 357 | Return type: tensor. The random variable with Gaussian distribution. |
| 358 | |
| 359 | Examples: |
| 360 | >>> import megengine.random as rand |
| 361 | >>> x = rand.normal(mean=0, std=1, size=(2, 2)) |
| 362 | >>> x.numpy() # doctest: +SKIP |
| 363 | array([[ 1.5534291 , -0.28356555], |
| 364 | [ 2.2230418 , -0.92425716]], dtype=float32) |
| 365 | """ |
| 366 | _seed = self._seed() if callable(self._seed) else self._seed |
| 367 | return _normal( |
| 368 | mean=mean, |
| 369 | std=std, |
| 370 | size=size, |
| 371 | seed=_seed, |
| 372 | device=self._device, |
| 373 | handle=self._handle, |
| 374 | ) |
| 375 | |
| 376 | def gamma( |
| 377 | self, |