mardi 5 janvier 2021

`numpy.empty()` and `numpy.random.rand()` same or different

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?




Aucun commentaire:

Enregistrer un commentaire