def inverse_weighting_function(distance, bin_width=None):
    """
    The "inverse" weighting function used in Yaffe and Tanay 2011.

    Parameters
    ----------
    distance : float
        The distance to compute a weight for, in base pairs.
    bin_width : Optional[int]
        The bin width in base pairs. Used to make results equivalent to Yaffe
        and Tanay 2011 by scaling ``distance`` to units of bins. Pass None to
        simply leave the distance in units of base pairs

    Returns
    -------
    float
        A weight appropriate for this distance.
    """
    if bin_width is not None:
        return 1 / (distance / float(bin_width) + 1)
    return float(1) / (distance + 1)
