import numpy as np
def mean(x):
= np.size(x) # x.size
N = 0.0
s for i in range(N):
+= x[i]
s return s / N
= np.random.default_rng() # instantiating an RNG class
rng = rng.normal(size = 10) # use rng instance to generate random numbers => ndarray
x x
array([ 0.53768287, 0.48044289, 0.41968892, 0.53617612, 0.12008546,
2.36768986, 0.17752883, 0.68915822, 0.07121943, -0.29874026])
# don't == floats/doubles np.isclose(mean(x), np.mean(x))
True