def _compute_delta(earlier_sample, later_sample, max_value):
    """Computes the difference between two samples of a value, considering
    that the value may have wrapped around in between"""
    if earlier_sample > later_sample:
        return later_sample - (max_value - earlier_sample)
    return later_sample - earlier_sample
