xxxxxxxxxx
np.random.randint(2, size=10) # Creates binary sample of size 10
np.random.randint(5, size=10) # Creates sample with 0-4 as values of size 10
np.random.randint(5, size=(2, 4))
xxxxxxxxxx
>>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0]) # random
>>> np.random.randint(1, size=10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
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)