MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / random_vector

Function random_vector

linear_algebra/src/lib.py:231–240  ·  view source on GitHub ↗

input: size (N) of the vector. random range (a,b) output: returns a random vector of size N, with random integer components between 'a' and 'b'.

(n: int, a: int, b: int)

Source from the content-addressed store, hash-verified

229
230
231def random_vector(n: int, a: int, b: int) -> Vector:
232 """
233 input: size (N) of the vector.
234 random range (a,b)
235 output: returns a random vector of size N, with
236 random integer components between 'a' and 'b'.
237 """
238 random.seed(None)
239 ans = [random.randint(a, b) for _ in range(n)]
240 return Vector(ans)
241
242
243class Matrix:

Callers

nothing calls this directly

Calls 1

VectorClass · 0.85

Tested by

no test coverage detected