pseudocode of sampling_rate