What’s the difference b/w np.random.randint()
and np.random.uniform()
?
I have gone through the numpy documentation but have not gotten a satisfactory understanding of the difference b/w them, except that the default precision of np.random.uniform()
is much greater than the integer values generated by np.random.randint()
Advertisement
Answer
np.random.randint() always returns integer value even when we decide to pick random numbers from a narrow spectrum –
>>> print(np.random.randint(2,size=10)) [0 0 0 0 0 0 1 0 1 0]
At other end, np.random.uniform() always return a unique number (floating numbers) for the same range.
>>> print(np.random.uniform(0,1,size=10)) [0.15925408 0.01435238 0.15866946 0.59042522 0.99683699 0.70776862 0.14471196 0.27948168 0.77953463 0.32399513]