Calculate max, min and mean values of element in an array
Question:
I have the following arrays:
x = [0.01067573 0.0139049 0.01713406 0.01902214 0.02228745 0.0243896
0.02575684 0.0281498 0.0303585 0.03053122 0.0282564 0.03066194
0.0318088 0.03290647 0.03438853 0.03613471 0.0383046 0.0365982
0.0348341 0.0289057 0.0122935 0.01067573 0.01067573 0.01067573
0.01067573 0.01067573 0.01067573 0.01067573 0.01067573 0.01067212
0.01046571]
y=[0.01067573 0.0139049 0.01713406 0.01994051 0.02141184 0.0238336
0.02698133 0.0296072 0.0320376 0.0291436 0.0262487 0.0279379
0.0294417 0.0308968 0.0323344 0.0337727 0.0336187 0.0357771
0.0340007 0.0282703 0.0123555 0.01095551 0.01067573 0.01083439
0.01067573 0.01067573 0.01075694 0.01095551 0.01067573 0.01076594
0.01098551]
z=[0.01067573 0.0139049 0.01713406 0.0188497 0.0213636 0.0248497
0.0252536 0.0274743 0.0295116 0.0274806 0.0273424 0.02900906
0.03005469 0.0308758 0.03167363 0.03314961 0.03595196 0.0375954
0.03869676 0.02937896 0.012627 0.01067573 0.01067573 0.01098724
0.01154837 0.01080896 0.01085163 0.01139469 0.01067573 0.01076688
0.01068204]
I want to calculate the maximum, minimum, and mean value of each element in these arrays, but I return one array of each attribute with respect of the length of the array. For example,
max = [0.01067573 0.0139049 0.01713406 0.01994765 0.02185929 0.02423337
0.02760071 0.0296107 0.0316786 0.0289268 0.0285128 0.03066194
0.0313552 0.03287471 0.03449902 0.03616078 0.0368397 0.0406049
0.035475 0.03232031 0.0124145 0.01067573 0.01067573 0.01100561
0.01067573 0.01067573 0.01085745 0.01067573 0.01067573 0.01071802
0.01072735]
Is there any way?
Answers:
IIUC use:
a = np.vstack((x, y, z))
max1 = np.max(a, axis=0)
avg1 = np.mean(a, axis=0)
min1 = np.min(a, axis=0)
Use selection sort algorithm to get elements in ascending order(min) or descending order(max)
I have the following arrays:
x = [0.01067573 0.0139049 0.01713406 0.01902214 0.02228745 0.0243896
0.02575684 0.0281498 0.0303585 0.03053122 0.0282564 0.03066194
0.0318088 0.03290647 0.03438853 0.03613471 0.0383046 0.0365982
0.0348341 0.0289057 0.0122935 0.01067573 0.01067573 0.01067573
0.01067573 0.01067573 0.01067573 0.01067573 0.01067573 0.01067212
0.01046571]
y=[0.01067573 0.0139049 0.01713406 0.01994051 0.02141184 0.0238336
0.02698133 0.0296072 0.0320376 0.0291436 0.0262487 0.0279379
0.0294417 0.0308968 0.0323344 0.0337727 0.0336187 0.0357771
0.0340007 0.0282703 0.0123555 0.01095551 0.01067573 0.01083439
0.01067573 0.01067573 0.01075694 0.01095551 0.01067573 0.01076594
0.01098551]
z=[0.01067573 0.0139049 0.01713406 0.0188497 0.0213636 0.0248497
0.0252536 0.0274743 0.0295116 0.0274806 0.0273424 0.02900906
0.03005469 0.0308758 0.03167363 0.03314961 0.03595196 0.0375954
0.03869676 0.02937896 0.012627 0.01067573 0.01067573 0.01098724
0.01154837 0.01080896 0.01085163 0.01139469 0.01067573 0.01076688
0.01068204]
I want to calculate the maximum, minimum, and mean value of each element in these arrays, but I return one array of each attribute with respect of the length of the array. For example,
max = [0.01067573 0.0139049 0.01713406 0.01994765 0.02185929 0.02423337
0.02760071 0.0296107 0.0316786 0.0289268 0.0285128 0.03066194
0.0313552 0.03287471 0.03449902 0.03616078 0.0368397 0.0406049
0.035475 0.03232031 0.0124145 0.01067573 0.01067573 0.01100561
0.01067573 0.01067573 0.01085745 0.01067573 0.01067573 0.01071802
0.01072735]
Is there any way?
IIUC use:
a = np.vstack((x, y, z))
max1 = np.max(a, axis=0)
avg1 = np.mean(a, axis=0)
min1 = np.min(a, axis=0)
Use selection sort algorithm to get elements in ascending order(min) or descending order(max)