Last active
July 27, 2017 07:47
-
-
Save Bktero/5ac05da9288c67c76f92fd7f6e2dbed9 to your computer and use it in GitHub Desktop.
[Python] Compute barycenter
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
import functools | |
import operator | |
points = [100, 66, 33, 0] | |
weights = [-50, 0, 0, 0] | |
numerator = functools.reduce(operator.add, [p * w for p, w in zip(points, weights)], 0) | |
denomimator = functools.reduce(operator.add, weights, 0) | |
barycenter = numerator / denomimator | |
print(numerator) | |
print(denomimator) | |
print(barycenter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment