Last active
June 30, 2022 14:21
-
-
Save phkahler/5e50441a2243cf0129f3ae50fddd3894 to your computer and use it in GitHub Desktop.
Compatibility based on 5 love language scores
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
''' Compatibility computed from scores of 5 love languages ''' | |
# the web quiz uses percentages | |
# https://www.5lovelanguages.com/quizzes/love-language | |
# scores for person 1 | |
p1 = [ 10, 9, 6, 5, 0 ] | |
# scores for person 2 (must be in the same order) | |
p2 = [ 3, 4, 9, 9, 5 ] | |
# by using the average as offset we can use raw scores from the old | |
# quiz, or percentages from the web quiz | |
avg = (sum(p1)+sum(p2))/10 | |
# we subtract the median (6) from all vector components | |
p11 = sum([(x-avg)*(x-avg) for x in p1]) | |
p22 = sum([(x-avg)*(x-avg) for x in p2]) | |
p12 = sum([(p1[x]-avg)*(p2[x]-avg) for x in range(5)]) | |
score = int(p12 / ((p11*p22)**0.5) * 100) | |
''' final score is the cosine of the angle between 2 vectors in R5 | |
probably want to avoid pairings that comes up negative as those | |
are pointing more in opposite directions than the same. It is | |
not clear what a good threshold is but I guess 30 to 50. ''' | |
print(score) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment