code: def _get_closest_samp_num(self, ref_samp_num, start_test_samp_num):
          
  
          if start_test_samp_num >= self.n_test:
              raise ValueError('Invalid starting test sample number.')
  
          ref_samp = self.ref_sample[ref_samp_num]
          test_samp = self.test_sample[start_test_samp_num]
          samp_diff = ref_samp - test_samp
  
          # Initialize running parameters
          closest_samp_num = start_test_samp_num
          smallest_samp_diff = abs(samp_diff)
  
          # Iterate through the testing samples
          for test_samp_num in range(start_test_samp_num, self.n_test):
              test_samp = self.test_sample[test_samp_num]
              samp_diff = ref_samp - test_samp
              abs_samp_diff = abs(samp_diff)
  
              # Found a better match
              if abs_samp_diff < smallest_samp_diff:
                  closest_samp_num = test_samp_num
                  smallest_samp_diff = abs_samp_diff
  
              # Stop iterating when the ref sample is first passed or reached
              if samp_diff <= 0:
                  break
  
          return closest_samp_num, smallest_samp_diff
docs: Return the closest testing sample number for the given reference
          sample number. Limit the search from start_test_samp_num.