How i can get random number as numpy.random.randn()

How i can get output as numpy for generating random numbers which is closer to both 0 and 1 in Float64

n = np.random.randn()

code in python

import numpy as np

for i in range(10):
  n = np.random.randn()
  print(n)

Output

-0.4473224332794838
0.5357461715087144
-0.05893440913028454
0.01697798466538489
-0.08155177013294897
1.6251740404687394
0.1333821970422605
0.4256883620078718
-1.2798846308240421
1.1278873504026543

as we can see the outputs are closer to both 0 and 1

how i can archive this with Julia code?

It’s a good idea to share what you’ve tried so far so folks know how best to help you.

If you’re looking for normally-distributed random numbers (centered around 0.0, going positive and negative but less frequent the farther you get from 0) the function is randn() in Julia. The equivilent Julia code would be

for _ in 1:10
      println(randn())
end

Or just println(randn(10)).

3 Likes