def inverse_distance_weights(distance, power):
    """
    A function for an calculating array of weights from an array of distances
    using an inverse distance function

    :param dist: array of distances
    :param power: the power o ft
    :return:
    an array of weights
    """
    # In IDW, weights are 1 / distance^(power)
    weights = 1.0 / distance**power

    # Make weights sum to one
    weights /= weights.sum(axis=0)

    return weights