random.rand to get random numbers

We get random number of uniform distribution.
dimensionInt, optional , the dimension of returned array
Output is the array of given shape

Example without dimension

import numpy as np
my_data=np.random.rand()
print(my_data) # 0.6601852461443163

Example with dimension

import numpy as np
my_data=np.random.rand(4)
print(my_data)
Output
[0.97823719 0.63318689 0.6091805  0.75746223]
import numpy as np
my_data=np.random.rand(4,3)
print(my_data)
Output
[[0.22050011 0.19774343 0.89542465]
 [0.35511363 0.76718542 0.65659122]
 [0.83884429 0.80796616 0.18510076]
 [0.85687065 0.21390647 0.83901793]]
import numpy as np
my_data=np.random.rand(1,2,3,4)
print(my_data)
Output
[[[[0.58082049 0.27719339 0.67736131 0.13333281]
   [0.22314567 0.76669328 0.49681767 0.72167221]
   [0.3233574  0.99742718 0.59929845 0.85654149]]

  [[0.60382161 0.31731253 0.74987002 0.07814571]
   [0.20946435 0.740648   0.48045316 0.9641322 ]
   [0.09219005 0.05010937 0.69697473 0.66450636]]]]
Numpy random.randint , Random Integers
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer