def sampling(value, sampling_frequency):
    """return the sampled value at a given sampling frequency"""
    ret_value = 0
    if value % (1 / sampling_frequency) <= 1 / sampling_frequency / 2:
        ret_value = value - value % (1 / sampling_frequency)
    else:
        ret_value = value - value % (1 / sampling_frequency
            ) + 1 / sampling_frequency
    return ret_value
