xxxxxxxxxx
from numpy import random
n = random.randint(lowerbound(inclusive), higherbound(exclusive))
xxxxxxxxxx
import numpy as np
np.random.seed(123)
print(np.random.randint(1,7)) # Random integer between 1 and 6
print(np.random.rand()) # Random float
np.random.random((2, 4)) # Matrix of 2 rows and 4 cols with random values
xxxxxxxxxx
np.random.rand(3,2)
array([[ 0.14022471, 0.96360618], #random
[ 0.37601032, 0.25528411], #random
[ 0.49313049, 0.94909878]]) #random
xxxxxxxxxx
import numpy as np
n = 2
m = 3
print(np.random.randn(n, m))
# prints random matrix with n rows and m columns
# example:
# array([[ 1.01267696, -1.85632995, 0.23078345],
# [ 0.34365521, -1.27063438, 2.90131288]])
xxxxxxxxxx
import numpy as np
# Generate a single random number between 0 and 1
random_number = np.random.random()
print(random_number)
# Generate an array of 5 random numbers between 0 and 1
random_array = np.random.random(5)
print(random_array)