mercredi 24 janvier 2018

Generate array of N sample from a list of N means and N sigmas

I have a numpy array of size N which contains [x,y] pixel locations. I want to slightly move every pixel in both x and y directions. What I want to achieve is to use every x value as the mean and randomly select new value around it from a normal distribution with configurable sigma. Same will be done for new y values

My problem is that I have to loop for every pixel and tediously use the following:

for i in range(len(pixels)):
    pixel = pixels[i]
    x = pixel[0]
    y = pixel[1]
    new_x = numpy.random.normal(x, std_deviation_x)
    new_y = numpy.random.normal(y, std_deviation_y)
    pixel[i][0] = new_x
    pixel[i][1] = new_y

I wonder if there is a way or any random function implementation which accept list of means, and list of sigmas to return list of N samples where each sample is of corresponding mean and sigma in the list




Aucun commentaire:

Enregistrer un commentaire