4 examples of 'np.random.exponential' in Python

Every line of 'np.random.exponential' 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
344def _exponential_internal(scale: float,
345 n: int,
346 antithetic: bool = False) -> ndarray:
347 u = rand(n)
348 u = minimum(u, 1.0 - np.finfo(np.float32).eps)
349 x: ndarray = log(1.0 - u) * (-scale)
350 return x
228def exponential(x):
229 """Exponential's function.
230
231 It can be used with 'n' variables and has minimum at -1.
232 Also, it is expected to be within [-1, 1] bounds.
233
234 Args:
235 x (np.array): An n-dimensional input array.
236
237 Returns:
238 y = -exp(-0.5 * sum(x^2))
239
240 """
241
242 # Calculating Sphere's function
243 s = sphere(x)
244
245 return -np.exp(-0.5 * s)
8def sampleFromExponential((lambdaParam, size)):
9 return numpy.random.exponential(lambdaParam, size)
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