Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

python - Normalise arrays within array?

I have a set of arrays within a larger array, for example:

[[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14],[15,16,17,18,19],[20,21,22,23,24]]

I need to normalise each array separately within the larger array. Here is what I have so far, which is creating the smaller arrays within the larger array:

small_array_size = 5 
large_array_size = small_array_size**2

large_list = list(results) 
small_lists = [[large_list[i*small_array_size+j] for i in range(small_array_size)]
               for j in range(small_array_size)]

This works and gives me the correct values in each array. The next step is the bit which is giving me trouble - normalising each small array separately. This is what I have, which works fine for the first group:

group_1 = small_lists[0]

normalised = [(group_1[i]-min(group_1))/(max(group_1)-min(group_1)) for i in range(small_array_size)]

How can I modify this to repeat for every array in small_lists?

question from:https://stackoverflow.com/questions/66049877/normalise-arrays-within-array

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...