2

I have a two different lists. One holds the values of the mean that was calculated from other sublists and another list which holds the standard deviation. Is there a way to find the best combination?Meaning to find the highest mean with the lowest standard deviation? This one is the list of means(with maximum 4.0):

[3.2577333333333334, 3.5, 3.381622807017544, 3.3605494505494504, 3.5, 3.1649999999999996, 4.0, 3.3724369747899154, 3.404678362573099, 3.4175, 3.5850000000000004, 3.3506896551724132, 3.3122834645669292, 3.125, 3.395, nan, 3.5850000000000004, nan, 3.4945999999999997]

This one is the list of standard deviation calculated:

[0.4258484028644727, 0.0, 0.37176233660557445, 0.4186736320715765, 0.165, 4.440892098500626e-16, 0.0, 0.4039026348822172, 0.38311593614201667, 0.0825, 0.08499999999999996, 0.41627395682935037, 0.40617175486607743, 0.37978612402245554, 0.32033363289488725, nan, 0.08499999999999995, nan, 0.28036590377576226]

What I want is to rank all the means based on the standard deviation. To rank them based on the top combinations those two can make.

For example the mean 3.2577333333333334 with standard deviation 0.4258484028644727 is worse than the mean 3.381622807017544 with standard deviation 0.37176233660557445.

The mean list is the average GPA for some courses, that is why I need to rank all of them based on the best combinations. I do not know if I can do something like this with something that already exists since I am new to this or if I should find my way of doing it.

piggy
  • 115
  • 10

1 Answers1

2

This will work:

list(zip(*(zip(means, stds)).sort()))
Igor Rivin
  • 4,632
  • 2
  • 23
  • 35
  • i get this error: AttributeError: 'zip' object has no attribute 'sort' – piggy May 16 '20 at 22:06
  • actually in python 3 probably it needs to be done like this: sorted(list(zip(*(zip(mean, stdev))))) . Thank you so much! @Igor – piggy May 16 '20 at 22:39
  • 1
    @piggy yes, it was a paren misplaced, see the edit. – Igor Rivin May 16 '20 at 22:47
  • Can I ask you something? If I want to change another list that is connected with them and I want to change the order of that list based on how these 2 lists changed then how can I do it? Should I post another question for it or is it relevant? @Igor Rivin – piggy May 16 '20 at 23:33
  • @piggy In the floating point context, just using `[means, stds, thirdlist]` instead of `[means, stds]` will do fine. – Igor Rivin May 17 '20 at 00:14