10 examples of 'numpy random uniform' in Python

Every line of 'numpy random uniform' 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
this disclaimer
208def _uniform(val_range):
209 """
210 Uniformly sample from the given range.
212 Args
213 val_range: A pair of lower and upper bound.
214 """
215 return np.random.uniform(val_range[0], val_range[1])

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

309def uniform(self, a, b):
310 """Get a random number in the range [a, b) or [a, b] depending on rounding."""
311 return a + (b - a) * self.random()
98def _uniform(self, np_array):
99 np_array[:] = np.random.uniform(self.low, self.high, len(np_array))
32def get_uniform(self):
33 return np.random.uniform(self.value[0], self.value[1])
47def uniform(self, low, high, axes, dtype=None):
48 """
49 Returns a tensor initialized with a uniform distribution from low to high with axes.
51 Arguments:
52 low: The lower limit of the distribution.
53 high: The upper limit of the distribution.
54 axes: The axes of the tensor.
55 dtype: If supplied, the type of the values.
57 Returns:
58 The initialized tensor.
60 """
61 if dtype is None:
62 dtype = self.dtype
64 return np.array(
65 self.rng.uniform(
66 low,
67 high,
68 ng.make_axes(axes).lengths),
69 dtype=dtype)
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
32def _random(self, size=None):
33 uu = np.random.uniform(size=size)
34 return np.exp(uu * self._fac + np.log(self.a))
19def uniform(low, up, size=None):
20 try:
21 return [np.random.uniform(a, b) for a, b in zip(low, up)]
22 except TypeError:
23 return [np.random.uniform(a, b) for a, b in zip([low] * size, [up] * size)]
360def rng_uniform(rng):
361 """Get the unform/randint from the rng."""
362 # prefer Generator.integers, fall back to RandomState.randint
363 return getattr(rng, 'integers', getattr(rng, 'randint', None))
379def _gen_random(self, X):
380 return np.random.random(size = X.shape[0])

Related snippets