code: def get_stats_for_pitch_method(method, freqs, samplerate=samplerate):
      """for a given pitch method and a list of frequency, generate a sinewave
      and get mean deviation"""
      means = np.zeros(len(freqs))
      medians = np.zeros(len(freqs))
      for freq, fn in zip(freqs, range(len(freqs))):
          s = sinewave(freq, 0.50).reshape(-1, hop_size)
          # s = (sinewave(freq, .50) + .0*sinewave(freq/2., .50)).reshape(-1, hop_size)
          p = pitch(method, buf_size, hop_size, samplerate=samplerate)
          candidates = np.zeros(len(s))
          # samples = np.zeros(buf_size)
          for frame, i in zip(s, range(len(s))):
              candidates[i] = p(frame)[0]
          # skip first few candidates
          candidates = candidates[4:]
          means[fn] = np.mean(candidates[candidates != 0] - freq)
          medians[fn] = np.median(candidates[candidates != 0] - freq)
          print(freq, means[fn], medians[fn])
      return means, medians
  
imports: import numpy
  from aubio import pitch
  import pylab
label_desc: Use image node_id 2 for calling a global function with example usage: get_stats_for_pitch_method(method, freqs, samplerate) and returns: means,  medians