I have an array X
containing R
rows and C
columns. I wish to generate a new array named a_array
where each element will be randomly generated based on the mean and standard deviation of its corresponding row in X
. What is the most pythonic and efficient way to do this using Numpy?
Currently, I am using a nested loop to generate element-wise numbers.
a_array = np.zeros(shape=(a_size, X.shape[0]))
for i in range(a_size):
for j in range(X.shape[0]):
a_array[i][j] = np.random.randint(low=X[i].mean()-X[i].std(), high=X[i].mean()+X[i].std())
EDIT: Sorry, I forgot something but I would also like to ensure that each row of a_array contains unique elements (There are no duplicate elements in any row). I have not been able to think of any way to achieve this till now.