mardi 17 octobre 2017

Saving the generated numpy random arrays in order without using lists in python?

I am trying to make couple of random arrays with numpy.random.poisson. I want to save each data sets in the order that they are generated. Now I am using list for doing that, I was wondering if there is a better way to do that which could have easy access to each set afterwards?

This is my code:

import numpy as np
data = np.random.randint(0, 255, (250, 250, 3)) 
total = np.zeros(data.shape)
listOfData = []
number = 10 #It could be any number
for i in range(number):
       new_total = np.random.poisson(lam=data)
       listOfData.append(new_total.flatten())
       total += new_total
firstSet = np.array(listOfData[0]).reshape(data.shape)

My data is a 3-D array.




Aucun commentaire:

Enregistrer un commentaire