jeudi 10 décembre 2020

Loop and multiply 3 different numpy arrays by random percents which add up to 100%

Suppose I have these three arrays.

array1 = np.array([4,5,6])
array2 = np.array([3,2,1])
array3 = np.array([2,3,5])

I want to create a loop that multiplies each array by a random percent, but the three percents must add up to 100%. For example on the first loop it may do the following

array1 * 30%
array2 * 20%
array3 * 50%

And on the second loop it does a different random percent for each array

array1 * 15%
array2 * 90%
array3 * 5%

If anyone has any ideas how to make this loop possible please let me know. Thanks!




Aucun commentaire:

Enregistrer un commentaire