title: How to determine the parameter alpha of a Complementary Filter?
body: <p>I know that the Complementary Filter has the functions of both LPF and HPF. But I think my understanding on the principal behind it is still unclear.</p>
  
  <p>I am quite new on digital signal processing, and maybe some very fundamental explanations will help a lot.</p>
  
  <p>Say I have a Complementary Filter as follows:</p>
  
  <pre><code>y = a * y + (1 - a) * x
  </code></pre>
  
  <p>Then my parameter <code>a</code> may be calculated by </p>
  
  <p><code>a = time_constant / (time_constant + sample_period)</code>,</p>
  
  <p>where the <code>sample_period</code> is simply the reciprocal of the <code>sampling_frequency</code>.</p>
  
  <p>The <code>time_constant</code> seems to be at my own choice.</p>
  
  <p><strong>My Questions:</strong></p>
  
  <ol>
  <li>What is the theory behind this calculation?</li>
  <li>How do we choose the <code>time_constant</code> properly?</li>
  </ol>
  
  <p><sub><strong>Note:</strong> I also <a href="https://robotics.stackexchange.com/q/1717">posted this question on <em>robotics</em></a>, as the answers there are likely to be slightly different in emphasis.</sub></p>