def potential_gravity(dists, power=2):
    """
    Takes a list of numeric distances and returns the sum of the values
    of a function of a distances. The function is 1/(d^power).
    """
    return sum([1.0/(d**power) for d in filter(lambda d: d > 0, dists)])