-
-
Save anonymous/a036818d6948f1909cec to your computer and use it in GitHub Desktop.
multiplying arrays
This file contains 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
# user_weights and user_predictions ordered by user_id, so that their weights and predictions match up. | |
user_weights = [.3, .2, .5] | |
user_predictions = [1.5, -1.0, 2.5] | |
result = | |
# multiply each element in array by the matching element in the next array, then the sum | |
# e.g. (.3*1.5)+(.2*-1)+(.5*2.5) = 1.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment