jeudi 19 avril 2018

Python random number generator sintax - clarification

I aiming to generate a sample of random numbers and I am using sample code , can you guys tell me what is the difference between these two pieces of code ? Is one more efficient than the other ?

Please find below :

Excerpt 1 :

def init_st(n):

l1 = np.random.choice([1, -1], size=(n, n))
return l1

Excerpt 2 :

def init_st(N):   
l1 = 2*np.random.randint(2, size=(N,N))-1
return l1

Thanks, I am new to coding




Aucun commentaire:

Enregistrer un commentaire