Last active
July 25, 2018 21:00
-
-
Save MatrixManAtYrService/5a83341d8aabc8313428597c128f5d68 to your computer and use it in GitHub Desktop.
controlling for pessimism and optimism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pessimist = [2, 2, 3, 2] | |
optimist = [4, 4, 5, 4] | |
def min_max(scores): | |
return list(map(lambda x : (x-min(scores))/(max(scores)-min(scores)), scores)) | |
print(min_max(pessimist)) # [0, 0, 1, 0] | |
print(min_max(optimist)) # [0, 0, 1, 0] | |
def div_avg(scores): | |
avg = float(sum(scores)/len(scores)) | |
return list(map(lambda x : x / avg, scores)) | |
print(div_avg(pessimist)) # [0.88, 0.88, 1.33, 0.88] | |
print(div_avg(optimist)) # [0.94, 0.94, 1.17, 0.94] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment