random.randn to get random numbers

We get random number of normal distribution following Gaussian Bell curve 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.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
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







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 Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer