vendredi 8 mai 2020

Create a matrix with np.random.normal

I need to create an nxn matrix in which the numbers in the cells are distributed following a Gaussian distribution. This code may not go well because it fills a cell with a sequence. how can I do?

mu, sigma = 8, 0.5 # mean and standard deviation

def KHead(nx, ny, mu, sigma):
KH0=np.zeros((nx,ny))
N=1000
for k in range(1,ny-1):
    for i in range(0,nx-1):
        KH0[(i,k)]= np.random.normal(mu, sigma, N )

return KH0



Aucun commentaire:

Enregistrer un commentaire