title: MATLAB's filtfilt() Algorithm
body: <p>I'm trying to reproduce a lengthy piece of MATLAB code in another language which has no built-in equivalent of the phaseless filter, <code>filtfilt()</code>. I'm trying to re-cast the function in terms of simple filtering (or convolution) operations so I can easily reproduce it. 
  I understand that this filtering operation is equivalent to forward filtering, followed by reverse filtering, but I'm seeing small differences at the edges of the data. Specifically:</p>
  
  <pre><code>data = [1 1 1 2 2 3 5 7 1 1 1 1 1];
  ker = [2 1 1];
  
  a = filtfilt(ker,1,data)
  
  b = fliplr( filter( ker, 1, fliplr( filter(ker, 1, data) ) ) )
  
  % a =
  %
  %   16   18   21   29   39   57   66   68   42   28   16   16   16
  %
  % b =
  %
  %   11   16   21   29   39   57   66   68   42   28   16   12    8
  </code></pre>
  
  <p>I've tried padding the data with zeros at one or both ends, before one or both of the filtering operations. I think I'm likely missing something obvious, but can't spot it.</p>