Note
Numpy (20) 본문
728x90
How to create a 2D array containing random floats between 5 and 10?
# Input
arr = np.arange(9).reshape(3,3)
# 1:
rand_arr = np.random.randint(low=5, high=10, size=(5,3)) + np.random.random((5,3))
# print(rand_arr)
# 2:
rand_arr = np.random.uniform(5,10, size=(5,3))
print(rand_arr)
# output
[[ 8.50061025 9.10531502 6.85867783]
[ 9.76262069 9.87717411 7.13466701]
[ 7.48966403 8.33409158 6.16808631]
[ 7.75010551 9.94535696 5.27373226]
[ 8.0850361 5.56165518 7.31244004]]
'Numpy' 카테고리의 다른 글
Numpy (22) (0) | 2022.08.13 |
---|---|
Numpy (21) (0) | 2022.08.12 |
Numpy (19) (0) | 2022.08.10 |
Numpy (18) (0) | 2022.08.09 |
Numpy (17) (0) | 2022.08.08 |
Comments