Skip to content

Instantly share code, notes, and snippets.

Created August 16, 2015 21:42
Show Gist options
  • Save anonymous/a036818d6948f1909cec to your computer and use it in GitHub Desktop.
Save anonymous/a036818d6948f1909cec to your computer and use it in GitHub Desktop.
multiplying arrays
# 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