10 examples of 'python random uniform' in Python

Every line of 'python 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
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()
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))
208def _uniform(val_range):
209 """
210 Uniformly sample from the given range.
211
212 Args
213 val_range: A pair of lower and upper bound.
214 """
215 return np.random.uniform(val_range[0], val_range[1])
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)]
27def _get_value(self, n):
28 return self._state.uniform(self.low, self.high, n)
35def uniform(bound):
36 return bound * (2 * random.random() - 1)
22def uniform(lower_list, upper_list, dimensions):
23 """Fill array """
24 if hasattr(lower_list, '__iter__'):
25 return [random.uniform(lower, upper)
26 for lower, upper in zip(lower_list, upper_list)]
27 else:
28 return [random.uniform(lower_list, upper_list)
29 for _ in range(dimensions)]
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.
50
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.
56
57 Returns:
58 The initialized tensor.
59
60 """
61 if dtype is None:
62 dtype = self.dtype
63
64 return np.array(
65 self.rng.uniform(
66 low,
67 high,
68 ng.make_axes(axes).lengths),
69 dtype=dtype)

Related snippets