title: Filter gain issue when using scipy.signal in Python
body: <p>I am attempting to filter a list of 16-bit two's-complement integer using a Butterworth filter generated using scipy.signal.butter and scipy.signal.lfilter (the list was extracted from a PCM-encoded .wav file). My primary language is C, however the majority of this project already exists in Python, and so I need to code this feature within the existing Python framework. </p>
  
  <p>The butterworth filters produced by scipy.signal (as far as I'm aware) are unity gain, and based upon the plot of the frequency response of the filter, that should be the case. I designed the filter using butter() and filtered my dataset using:</p>
  
  <pre><code>data.l = lfilter(b, a, data.l)
  </code></pre>
  
  <p>where data.l is a class containing an list 'l' containing PCM data, and 'b' and 'a' are the coefficients produced by butter().</p>
  
  <p>However, regardless of the PCM data that I send in, the filter appears to be applying non-unity gain.</p>
  
  <p>For example, filtering full-bandwidth pink noise with <code>max(data.l) = 32,767</code>, and <code>min(data.l) = -32,768</code> before filtering (as expected for a 16-bit PCM signal) returns a signal with approximately 5% increased gain in the passband. i.e <code>max(data.l) = 34,319.0057</code> and <code>min(data.l) = -37,593</code>.</p>
  
  <p>The filter appears to be correctly filtering the signal apart from the gain; if I save this PCM data back into a .wav file, and compare a spectrogram of the data to the original signal, the frequency response is exactly as would be expected from my test filters. It seems to be functioning perfectly except for the odd increase in gain?</p>
  
  <p>Obviously I can just rescale this output down to fit into my 16-bit PCM dataset, however I am writing this as part of a wider set of signal processing modules that are designed to be flexible and eventually include non-unity gain filters. For this reason, I want to attempt to figure out why this gain is being applied so as to potentially fix the issue, and not be arbitrarily rescaling the output of my butter() filter.</p>
  
  <p>Does anyone with experience with scipy.signal have an idea as to why this may be the case?</p>