Skip to content

Instantly share code, notes, and snippets.

@MatrixManAtYrService
Last active July 25, 2018 21:00
Show Gist options
  • Save MatrixManAtYrService/5a83341d8aabc8313428597c128f5d68 to your computer and use it in GitHub Desktop.
Save MatrixManAtYrService/5a83341d8aabc8313428597c128f5d68 to your computer and use it in GitHub Desktop.
controlling for pessimism and optimism
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