In NumPy there are two functions, one is numpy.random.rand() and another is numpy.empty(). Both functions are giving me same output.
Code:
>>> import numpy as np
>>> np.random.rand(3,2)
array([[0.54372255, 0.68730993],
[0.97759727, 0.39876009],
[0.47325882, 0.57949219]])
>>> np.empty([3,2])
array([[0.54372255, 0.68730993],
[0.97759727, 0.39876009],
[0.47325882, 0.57949219]])
Because both of them are giving the same output, both are the same or different? here I mean with same that both functions have similar implementations or they have different implementations
If both are different then which one is better or efficient?
numpyuses memory available from your previous initialization to claim memory fornp.empty(), because it is a block of memory with an appropriate size.