random.randn to get random numbers
We get random number of normal distribution following Gaussian Bell curve distribution
dimension | Int, optional , the dimension of returned array |
Output is the array of given shape
Example without dimension
import numpy as np
my_data=np.random.randn()
print(my_data) # 0.3407387578227291
Example with dimension
import numpy as np
my_data=np.random.randn(4)
print(my_data)
Output
[-0.46185619 -0.5258339 1.39681228 0.74958391]
import numpy as np
my_data=np.random.randn(4,3)
print(my_data)
Output
[[ 2.55561162 0.67491164 -1.34461519]
[-0.27507307 0.97319295 1.82271703]
[-0.44200806 -1.16062905 2.6366758 ]
[-0.9891809 0.99041475 1.17115226]]
import numpy as np
my_data=np.random.randn(1,2,3,4)
print(my_data)
Output
[[[[-0.67129892 -0.08907703 -0.3495578 1.53348778]
[-1.08704517 -0.20113398 0.25851424 -0.99002334]
[-0.6590043 1.07602213 -1.87964251 -0.17996415]]
[[ 0.74772442 0.92772931 0.82296413 -0.75688895]
[-0.4476312 -1.17030355 1.12248299 0.09346895]
[-0.34555247 1.34330406 0.24308904 -1.46213067]]]]
«Numpy
random.randint , Random Integers
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com