How to use 'numpy .random' in Python

Every line of 'numpy .random' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
178def rand(*args, **kargs):
179 low, high = kargs["low"], kargs["high"]
180 if low == high:
181 return np.full(kargs["size"], low)
182 else:
183 return rs.rand(*kargs["size"])*(high - low) + low
1712def random(self, array_or_shape):
1713 """
1714 Generate a random sample with the same type as the layer.
1715 For an Exponential layer, draws from the exponential distribution
1716 with the rate determined by the params attribute.
1717
1718 Used for generating initial configurations for Monte Carlo runs.
1719
1720 Args:
1721 array_or_shape (array or shape tuple):
1722 If tuple, then this is taken to be the shape.
1723 If array, then its shape is used.
1724
1725 Returns:
1726 tensor: Random sample with desired shape.
1727
1728 """
1729 try:
1730 shape = be.shape(array_or_shape)
1731 except Exception:
1732 shape = array_or_shape
1733
1734 r = self.rand(shape)
1735 return be.divide(self.params.loc, -be.log(r))

Related snippets