code: def butter_lowpass_filter(data, sample_rate, cutoff=10, order=4, plot=False):
      
      
  
      nyquist = 0.5 * sample_rate
      normal_cutoff = cutoff / nyquist
      b, a = butter(order, normal_cutoff, btype='low', analog=False)
      
      if plot:
          w, h = freqz(b, a, worN=8000)
          plt.subplot(2, 1, 1)
          plt.plot(0.5*sample_rate*w/np.pi, np.abs(h), 'b')
          plt.plot(cutoff, 0.5*np.sqrt(2), 'ko')
          plt.axvline(cutoff, color='k')
          plt.xlim(0, 0.5*sample_rate)
          plt.title("Lowpass Filter Frequency Response")
          plt.xlabel('Frequency [Hz]')
          plt.grid()
          plt.show()
  
      y = lfilter(b, a, data)
  
      return y
docs: `Low-pass filter <http://stackoverflow.com/questions/25191620/
          creating-lowpass-filter-in-scipy-understanding-methods-and-units>`_ data by the [order]th order zero lag Butterworth filter
          whose cut frequency is set to [cutoff] Hz.
  
          :param data: time-series data,
          :type data: numpy array of floats
          :param: sample_rate: data sample rate
          :type sample_rate: integer
          :param cutoff: filter cutoff
          :type cutoff: float
          :param order: order
          :type order: integer
          :return y: low-pass-filtered data
          :rtype y: numpy array of floats
  
          :Examples:
  
          >>> from mhealthx.signals import butter_lowpass_filter
          >>> data = np.random.random(100)
          >>> sample_rate = 10
          >>> cutoff = 5
          >>> order = 4
          >>> y = butter_lowpass_filter(data, sample_rate, cutoff, order)