def dist2weights_linear(dist, max_r, max_w=1, min_w=0):
    """Linear distance weighting.

    Parameters
    ----------
    dist: float or np.ndarray
        the distances to be transformed into weights.
    max_r: float
        maximum radius of the neighbourhood considered.
    max_w: int (default=1)
        maximum weight to be considered.
    min_w: float (default=0)
        minimum weight to be considered.

    Returns
    -------
    weights: np.ndarray, array_like, shape (num. of retrievable candidates)
        values of the weight of the neighs inferred from the distances.

    """
    weights = (max_w - dist)*((max_w-min_w)/float(max_r))+min_w
    return weights