Why is the first value in digital first-order IIR filter impulse response not the largest?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
1












When I create a digital first-order IIR low-pass filter with scipy (code below), I get the following coefficients:



B: [ 0.1367 0.1367]
A: [ 1. -0.7265]


The impulse response of this filter does not look like most text-book examples in that the first value is not the largest.



Why is this so? Does it have to be so?



If I want to make an FIR filter to mimic such a first-order IIR low-pass filter, should it be a normal exponential decay shape, or does it need the first value "tweaked" in this manner?



Impulse response



import numpy as np
from scipy.signal import butter, lfilter
import matplotlib.pyplot as plt

b, a = butter(1, .1, btype='lowpass')
print('B:', b)
print('A:', a)

x = np.zeros(1000)
x[0] = 1.

xf = lfilter(b, a, x)

plt.figure()
plt.plot(x,'o', label='impulse')
plt.plot(xf,'s-', label='response')
plt.xlim(-1, 10)
plt.ylim(-.1, .3)
plt.legend()






share|improve this question


























    up vote
    5
    down vote

    favorite
    1












    When I create a digital first-order IIR low-pass filter with scipy (code below), I get the following coefficients:



    B: [ 0.1367 0.1367]
    A: [ 1. -0.7265]


    The impulse response of this filter does not look like most text-book examples in that the first value is not the largest.



    Why is this so? Does it have to be so?



    If I want to make an FIR filter to mimic such a first-order IIR low-pass filter, should it be a normal exponential decay shape, or does it need the first value "tweaked" in this manner?



    Impulse response



    import numpy as np
    from scipy.signal import butter, lfilter
    import matplotlib.pyplot as plt

    b, a = butter(1, .1, btype='lowpass')
    print('B:', b)
    print('A:', a)

    x = np.zeros(1000)
    x[0] = 1.

    xf = lfilter(b, a, x)

    plt.figure()
    plt.plot(x,'o', label='impulse')
    plt.plot(xf,'s-', label='response')
    plt.xlim(-1, 10)
    plt.ylim(-.1, .3)
    plt.legend()






    share|improve this question
























      up vote
      5
      down vote

      favorite
      1









      up vote
      5
      down vote

      favorite
      1






      1





      When I create a digital first-order IIR low-pass filter with scipy (code below), I get the following coefficients:



      B: [ 0.1367 0.1367]
      A: [ 1. -0.7265]


      The impulse response of this filter does not look like most text-book examples in that the first value is not the largest.



      Why is this so? Does it have to be so?



      If I want to make an FIR filter to mimic such a first-order IIR low-pass filter, should it be a normal exponential decay shape, or does it need the first value "tweaked" in this manner?



      Impulse response



      import numpy as np
      from scipy.signal import butter, lfilter
      import matplotlib.pyplot as plt

      b, a = butter(1, .1, btype='lowpass')
      print('B:', b)
      print('A:', a)

      x = np.zeros(1000)
      x[0] = 1.

      xf = lfilter(b, a, x)

      plt.figure()
      plt.plot(x,'o', label='impulse')
      plt.plot(xf,'s-', label='response')
      plt.xlim(-1, 10)
      plt.ylim(-.1, .3)
      plt.legend()






      share|improve this question














      When I create a digital first-order IIR low-pass filter with scipy (code below), I get the following coefficients:



      B: [ 0.1367 0.1367]
      A: [ 1. -0.7265]


      The impulse response of this filter does not look like most text-book examples in that the first value is not the largest.



      Why is this so? Does it have to be so?



      If I want to make an FIR filter to mimic such a first-order IIR low-pass filter, should it be a normal exponential decay shape, or does it need the first value "tweaked" in this manner?



      Impulse response



      import numpy as np
      from scipy.signal import butter, lfilter
      import matplotlib.pyplot as plt

      b, a = butter(1, .1, btype='lowpass')
      print('B:', b)
      print('A:', a)

      x = np.zeros(1000)
      x[0] = 1.

      xf = lfilter(b, a, x)

      plt.figure()
      plt.plot(x,'o', label='impulse')
      plt.plot(xf,'s-', label='response')
      plt.xlim(-1, 10)
      plt.ylim(-.1, .3)
      plt.legend()








      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 3 at 11:34









      Matt L.

      45.2k13678




      45.2k13678










      asked Sep 3 at 10:47









      adr

      404




      404




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          A causal first-order IIR filter is characterized by the following difference equation:



          $$y[n]=b_0x[n]+b_1x[n-1]-a_1y[n-1]tag1$$



          with $x[n]$ the input signal, and $y[n]$ the output signal. The impulse response of that system can be computed via the $mathcalZ$-transform or otherwise, and it turns out to be



          $$h[n]=b_0delta[n]+(-a_1)^n-1(b_1-b_0a_1)u[n-1]tag2$$



          where $delta[n]$ is the unit impulse, and $u[n]$ is the unit step sequence. Assuming that the filter is stable, we can conclude that $|a_1|<1$ is satisfied. Consequently, $|h[0]|>|h[n]|$ for $n>0$ is satisfied if and only if



          $$|b_0|>|b_1-b_0a_1|tag3$$



          holds.



          With $b_0=b_1$ and $a_1<0$ as in your example, condition $(3)$ can never be satisfied, and, consequently, the maximum magnitude of the impulse response is not assumed at index $n=0$.



          EDIT:



          I add more details referring to your filter design problem. A Butterworth low pass filter's frequency response satisfies $H(1)=1$ (DC) and $H(-1)=0$ (Nyquist). With



          $$H(z)=fracb_0+b_1z^-11+a_1z^-1tag4$$



          we have the following requirements on the coefficients:



          $$H(1)=fracb_0+b_11+a_1=1\
          H(-1)=fracb_0-b_11-a_1=0tag5$$



          which gives



          $$b_0=b_1quadtextrm and quad a_1=2b_0-1tag6$$



          From the stability condition $|a_1|<1$ we get



          $$|2b_0-1|<1Longrightarrow 0<b_0<1tag7$$



          Combining the constraints $(6)$ and $(7)$ with the inequality $(3)$ yields



          $$1 >b_0>frac12tag8$$



          If $(8)$ is satisfied, $h[0]$ will have the largest magnitude, otherwise it won't. Now it turns out that the exact value of $b_0$ depends on the desired cut-off frequency of the low pass filter. For cut-off frequencies less than $frac12$ (i.e., less than half the Nyquist frequency), you get $b_0<frac12$, and hence $|h[0]|$ is smaller than the maximum magnitude of the impulse response. Only for cut-off frequencies greater than half the Nyquist frequency do you get $|h[0]|>|h[n]|$, $n>0$.



          So to directly answer the question in your title: the first impulse response value is not the largest (in magnitude) because the filter coefficients do not satisfy inequality $(3)$, and in your example of a (first-order) Butterworth low pass filter this happens because the cut-off frequency is smaller than half the Nyquist frequency.






          share|improve this answer






















          • I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
            – adr
            Sep 3 at 12:37










          • I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
            – Dan Boschen
            Sep 3 at 13:31







          • 1




            @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
            – Matt L.
            Sep 3 at 15:18






          • 1




            @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
            – Matt L.
            Sep 3 at 15:23






          • 1




            @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
            – adr
            Sep 3 at 19:00

















          up vote
          2
          down vote














          The impulse response of this filter does not look like most text-book
          examples in that the first value is not the largest.




          That's simply an issue with interpreting the text books the wrong way. There is nothing special about the first sample, and there is no reason at all, why it would have to be the largest. I'm quite sure that none of the text box actually says anything about this.



          Some very simple "beginner" filters just happen to have this property, so you looked at a bunch of pictures and formed a conclusion & generalization that's neither supported by the text or the math.






          share|improve this answer



























            up vote
            1
            down vote













            Starting from an FIR filter with an absolutely flat frequency response:




            • [ 1 0 0 0 0 ] has a delay of one sample,


            • [ 0 0 1 0 0 ] has a delay of three samples.

            The largest coefficient corresponds to the filter's group delay. For a lowpass filter like [ 1 -2 7 -2 1] it is the group delay for the DC component — if you look at the step [ 0 0 0 1 1 1 1 1 1 1 ] response [ 0 0 0 1 -1 6 4 5 5 5] it is fairly obvious what the filter's DC delay is. If you design an FIR lowpass filter with uniform group delay for all passband frequencies, it will have a single largest coefficient in the middle bin, while the length of the filter corresponds to the filter's selectivity.



            The same filter with no delay would be non-causal, as the small coefficients before the large one would have negative indexes.



            For IIR filters, it's slightly less obvious, because they have two coefficient sets and are unlikely to have flat group delay, but you can still get better stopband attenuation and sharper falloffs with larger delays.






            share|improve this answer



























              up vote
              0
              down vote













              The confusion might arise from what people mean by first order. In some places, like:



              • SE.DSP: What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?


              • Tutorial on a very simple yet useful filter: the first order IIR filter, J. Arzi, 2016

              a first order filter follows the input ($x$)/output ($y$) equation:



              $$ y[n] = (1-lambda)y[n-1]+lambda x[n],,$$
              or equivalently in tracking form:
              $$ y[n] = y[n-1]+lambda (x[n]-y[n-1]),.$$



              It has numerous names, including first order exponential averaging low-pass filter or exponentially weighted moving average (EWMA). More details are given in



              • What is the name of these simple filter algorithms?

              • Is there a technical term for this simple method of smoothing out a signal?

              In that case, the impulse response $h$ of the filter is explicit. For $k< 0 $, $h[k] = 0$, and for $kge 0 $, $h[k] = lambda(1-lambda)^k$, where $0<lambda < 1$ is a smoothing factor. In this situation, the "first" value $h[0] $ is indeed the largest, since the exponential sequence $lambda(1-lambda)^k$ is decreasing:



              Impulse responses for exponential first order filters



              Other filter families are called first order, with additional constraints, like Butterworth's for which Mmatt's answer is complete.






              share|improve this answer






















                Your Answer




                StackExchange.ifUsing("editor", function ()
                return StackExchange.using("mathjaxEditing", function ()
                StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
                );
                );
                , "mathjax-editing");

                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "295"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                noCode: true, onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdsp.stackexchange.com%2fquestions%2f51709%2fwhy-is-the-first-value-in-digital-first-order-iir-filter-impulse-response-not-th%23new-answer', 'question_page');

                );

                Post as a guest






























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                6
                down vote



                accepted










                A causal first-order IIR filter is characterized by the following difference equation:



                $$y[n]=b_0x[n]+b_1x[n-1]-a_1y[n-1]tag1$$



                with $x[n]$ the input signal, and $y[n]$ the output signal. The impulse response of that system can be computed via the $mathcalZ$-transform or otherwise, and it turns out to be



                $$h[n]=b_0delta[n]+(-a_1)^n-1(b_1-b_0a_1)u[n-1]tag2$$



                where $delta[n]$ is the unit impulse, and $u[n]$ is the unit step sequence. Assuming that the filter is stable, we can conclude that $|a_1|<1$ is satisfied. Consequently, $|h[0]|>|h[n]|$ for $n>0$ is satisfied if and only if



                $$|b_0|>|b_1-b_0a_1|tag3$$



                holds.



                With $b_0=b_1$ and $a_1<0$ as in your example, condition $(3)$ can never be satisfied, and, consequently, the maximum magnitude of the impulse response is not assumed at index $n=0$.



                EDIT:



                I add more details referring to your filter design problem. A Butterworth low pass filter's frequency response satisfies $H(1)=1$ (DC) and $H(-1)=0$ (Nyquist). With



                $$H(z)=fracb_0+b_1z^-11+a_1z^-1tag4$$



                we have the following requirements on the coefficients:



                $$H(1)=fracb_0+b_11+a_1=1\
                H(-1)=fracb_0-b_11-a_1=0tag5$$



                which gives



                $$b_0=b_1quadtextrm and quad a_1=2b_0-1tag6$$



                From the stability condition $|a_1|<1$ we get



                $$|2b_0-1|<1Longrightarrow 0<b_0<1tag7$$



                Combining the constraints $(6)$ and $(7)$ with the inequality $(3)$ yields



                $$1 >b_0>frac12tag8$$



                If $(8)$ is satisfied, $h[0]$ will have the largest magnitude, otherwise it won't. Now it turns out that the exact value of $b_0$ depends on the desired cut-off frequency of the low pass filter. For cut-off frequencies less than $frac12$ (i.e., less than half the Nyquist frequency), you get $b_0<frac12$, and hence $|h[0]|$ is smaller than the maximum magnitude of the impulse response. Only for cut-off frequencies greater than half the Nyquist frequency do you get $|h[0]|>|h[n]|$, $n>0$.



                So to directly answer the question in your title: the first impulse response value is not the largest (in magnitude) because the filter coefficients do not satisfy inequality $(3)$, and in your example of a (first-order) Butterworth low pass filter this happens because the cut-off frequency is smaller than half the Nyquist frequency.






                share|improve this answer






















                • I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                  – adr
                  Sep 3 at 12:37










                • I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                  – Dan Boschen
                  Sep 3 at 13:31







                • 1




                  @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                  – Matt L.
                  Sep 3 at 15:18






                • 1




                  @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                  – Matt L.
                  Sep 3 at 15:23






                • 1




                  @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                  – adr
                  Sep 3 at 19:00














                up vote
                6
                down vote



                accepted










                A causal first-order IIR filter is characterized by the following difference equation:



                $$y[n]=b_0x[n]+b_1x[n-1]-a_1y[n-1]tag1$$



                with $x[n]$ the input signal, and $y[n]$ the output signal. The impulse response of that system can be computed via the $mathcalZ$-transform or otherwise, and it turns out to be



                $$h[n]=b_0delta[n]+(-a_1)^n-1(b_1-b_0a_1)u[n-1]tag2$$



                where $delta[n]$ is the unit impulse, and $u[n]$ is the unit step sequence. Assuming that the filter is stable, we can conclude that $|a_1|<1$ is satisfied. Consequently, $|h[0]|>|h[n]|$ for $n>0$ is satisfied if and only if



                $$|b_0|>|b_1-b_0a_1|tag3$$



                holds.



                With $b_0=b_1$ and $a_1<0$ as in your example, condition $(3)$ can never be satisfied, and, consequently, the maximum magnitude of the impulse response is not assumed at index $n=0$.



                EDIT:



                I add more details referring to your filter design problem. A Butterworth low pass filter's frequency response satisfies $H(1)=1$ (DC) and $H(-1)=0$ (Nyquist). With



                $$H(z)=fracb_0+b_1z^-11+a_1z^-1tag4$$



                we have the following requirements on the coefficients:



                $$H(1)=fracb_0+b_11+a_1=1\
                H(-1)=fracb_0-b_11-a_1=0tag5$$



                which gives



                $$b_0=b_1quadtextrm and quad a_1=2b_0-1tag6$$



                From the stability condition $|a_1|<1$ we get



                $$|2b_0-1|<1Longrightarrow 0<b_0<1tag7$$



                Combining the constraints $(6)$ and $(7)$ with the inequality $(3)$ yields



                $$1 >b_0>frac12tag8$$



                If $(8)$ is satisfied, $h[0]$ will have the largest magnitude, otherwise it won't. Now it turns out that the exact value of $b_0$ depends on the desired cut-off frequency of the low pass filter. For cut-off frequencies less than $frac12$ (i.e., less than half the Nyquist frequency), you get $b_0<frac12$, and hence $|h[0]|$ is smaller than the maximum magnitude of the impulse response. Only for cut-off frequencies greater than half the Nyquist frequency do you get $|h[0]|>|h[n]|$, $n>0$.



                So to directly answer the question in your title: the first impulse response value is not the largest (in magnitude) because the filter coefficients do not satisfy inequality $(3)$, and in your example of a (first-order) Butterworth low pass filter this happens because the cut-off frequency is smaller than half the Nyquist frequency.






                share|improve this answer






















                • I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                  – adr
                  Sep 3 at 12:37










                • I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                  – Dan Boschen
                  Sep 3 at 13:31







                • 1




                  @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                  – Matt L.
                  Sep 3 at 15:18






                • 1




                  @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                  – Matt L.
                  Sep 3 at 15:23






                • 1




                  @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                  – adr
                  Sep 3 at 19:00












                up vote
                6
                down vote



                accepted







                up vote
                6
                down vote



                accepted






                A causal first-order IIR filter is characterized by the following difference equation:



                $$y[n]=b_0x[n]+b_1x[n-1]-a_1y[n-1]tag1$$



                with $x[n]$ the input signal, and $y[n]$ the output signal. The impulse response of that system can be computed via the $mathcalZ$-transform or otherwise, and it turns out to be



                $$h[n]=b_0delta[n]+(-a_1)^n-1(b_1-b_0a_1)u[n-1]tag2$$



                where $delta[n]$ is the unit impulse, and $u[n]$ is the unit step sequence. Assuming that the filter is stable, we can conclude that $|a_1|<1$ is satisfied. Consequently, $|h[0]|>|h[n]|$ for $n>0$ is satisfied if and only if



                $$|b_0|>|b_1-b_0a_1|tag3$$



                holds.



                With $b_0=b_1$ and $a_1<0$ as in your example, condition $(3)$ can never be satisfied, and, consequently, the maximum magnitude of the impulse response is not assumed at index $n=0$.



                EDIT:



                I add more details referring to your filter design problem. A Butterworth low pass filter's frequency response satisfies $H(1)=1$ (DC) and $H(-1)=0$ (Nyquist). With



                $$H(z)=fracb_0+b_1z^-11+a_1z^-1tag4$$



                we have the following requirements on the coefficients:



                $$H(1)=fracb_0+b_11+a_1=1\
                H(-1)=fracb_0-b_11-a_1=0tag5$$



                which gives



                $$b_0=b_1quadtextrm and quad a_1=2b_0-1tag6$$



                From the stability condition $|a_1|<1$ we get



                $$|2b_0-1|<1Longrightarrow 0<b_0<1tag7$$



                Combining the constraints $(6)$ and $(7)$ with the inequality $(3)$ yields



                $$1 >b_0>frac12tag8$$



                If $(8)$ is satisfied, $h[0]$ will have the largest magnitude, otherwise it won't. Now it turns out that the exact value of $b_0$ depends on the desired cut-off frequency of the low pass filter. For cut-off frequencies less than $frac12$ (i.e., less than half the Nyquist frequency), you get $b_0<frac12$, and hence $|h[0]|$ is smaller than the maximum magnitude of the impulse response. Only for cut-off frequencies greater than half the Nyquist frequency do you get $|h[0]|>|h[n]|$, $n>0$.



                So to directly answer the question in your title: the first impulse response value is not the largest (in magnitude) because the filter coefficients do not satisfy inequality $(3)$, and in your example of a (first-order) Butterworth low pass filter this happens because the cut-off frequency is smaller than half the Nyquist frequency.






                share|improve this answer














                A causal first-order IIR filter is characterized by the following difference equation:



                $$y[n]=b_0x[n]+b_1x[n-1]-a_1y[n-1]tag1$$



                with $x[n]$ the input signal, and $y[n]$ the output signal. The impulse response of that system can be computed via the $mathcalZ$-transform or otherwise, and it turns out to be



                $$h[n]=b_0delta[n]+(-a_1)^n-1(b_1-b_0a_1)u[n-1]tag2$$



                where $delta[n]$ is the unit impulse, and $u[n]$ is the unit step sequence. Assuming that the filter is stable, we can conclude that $|a_1|<1$ is satisfied. Consequently, $|h[0]|>|h[n]|$ for $n>0$ is satisfied if and only if



                $$|b_0|>|b_1-b_0a_1|tag3$$



                holds.



                With $b_0=b_1$ and $a_1<0$ as in your example, condition $(3)$ can never be satisfied, and, consequently, the maximum magnitude of the impulse response is not assumed at index $n=0$.



                EDIT:



                I add more details referring to your filter design problem. A Butterworth low pass filter's frequency response satisfies $H(1)=1$ (DC) and $H(-1)=0$ (Nyquist). With



                $$H(z)=fracb_0+b_1z^-11+a_1z^-1tag4$$



                we have the following requirements on the coefficients:



                $$H(1)=fracb_0+b_11+a_1=1\
                H(-1)=fracb_0-b_11-a_1=0tag5$$



                which gives



                $$b_0=b_1quadtextrm and quad a_1=2b_0-1tag6$$



                From the stability condition $|a_1|<1$ we get



                $$|2b_0-1|<1Longrightarrow 0<b_0<1tag7$$



                Combining the constraints $(6)$ and $(7)$ with the inequality $(3)$ yields



                $$1 >b_0>frac12tag8$$



                If $(8)$ is satisfied, $h[0]$ will have the largest magnitude, otherwise it won't. Now it turns out that the exact value of $b_0$ depends on the desired cut-off frequency of the low pass filter. For cut-off frequencies less than $frac12$ (i.e., less than half the Nyquist frequency), you get $b_0<frac12$, and hence $|h[0]|$ is smaller than the maximum magnitude of the impulse response. Only for cut-off frequencies greater than half the Nyquist frequency do you get $|h[0]|>|h[n]|$, $n>0$.



                So to directly answer the question in your title: the first impulse response value is not the largest (in magnitude) because the filter coefficients do not satisfy inequality $(3)$, and in your example of a (first-order) Butterworth low pass filter this happens because the cut-off frequency is smaller than half the Nyquist frequency.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 3 at 16:28

























                answered Sep 3 at 11:33









                Matt L.

                45.2k13678




                45.2k13678











                • I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                  – adr
                  Sep 3 at 12:37










                • I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                  – Dan Boschen
                  Sep 3 at 13:31







                • 1




                  @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                  – Matt L.
                  Sep 3 at 15:18






                • 1




                  @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                  – Matt L.
                  Sep 3 at 15:23






                • 1




                  @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                  – adr
                  Sep 3 at 19:00
















                • I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                  – adr
                  Sep 3 at 12:37










                • I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                  – Dan Boschen
                  Sep 3 at 13:31







                • 1




                  @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                  – Matt L.
                  Sep 3 at 15:18






                • 1




                  @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                  – Matt L.
                  Sep 3 at 15:23






                • 1




                  @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                  – adr
                  Sep 3 at 19:00















                I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                – adr
                Sep 3 at 12:37




                I'm afraid this doesn't help me understand the bigger picture. I know how the coefficients produce the observed impulse response. But why are the coefficients the way they are? Does it have something to do with analog vs. digital?
                – adr
                Sep 3 at 12:37












                I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                – Dan Boschen
                Sep 3 at 13:31





                I believe it is because he has zeros in his filter implementation (it is not completely IIR but FIR/IIR) and a true minimum phase IIR would have trailing echos only. (??) Is that true @MattL?
                – Dan Boschen
                Sep 3 at 13:31





                1




                1




                @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                – Matt L.
                Sep 3 at 15:18




                @DanBoschen: The zeros don't really matter, it depends on the value of the cut-off frequency. For cut-off frequencies less than half the Nyquist frequency, the first value of the impulse response has a smaller magnitude than the second value. See my edited answer.
                – Matt L.
                Sep 3 at 15:18




                1




                1




                @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                – Matt L.
                Sep 3 at 15:23




                @adr: Sure, any good low pass filter has a zero at Nyquist. Note though that this is just an ordinary IIR filter. IIR filters normally have a recursive and a feed forward path. What you mean is called an "all pole filter", i.e., a filter with only poles away from the origin of the z-plane, with just a constant in the numerator.
                – Matt L.
                Sep 3 at 15:23




                1




                1




                @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                – adr
                Sep 3 at 19:00




                @MattL In retrospect, my question should have been: why does the first value not lie on the exponential curve defined by the subsequent values? Anyway, things are clearer to me now, which is what the objective was!
                – adr
                Sep 3 at 19:00










                up vote
                2
                down vote














                The impulse response of this filter does not look like most text-book
                examples in that the first value is not the largest.




                That's simply an issue with interpreting the text books the wrong way. There is nothing special about the first sample, and there is no reason at all, why it would have to be the largest. I'm quite sure that none of the text box actually says anything about this.



                Some very simple "beginner" filters just happen to have this property, so you looked at a bunch of pictures and formed a conclusion & generalization that's neither supported by the text or the math.






                share|improve this answer
























                  up vote
                  2
                  down vote














                  The impulse response of this filter does not look like most text-book
                  examples in that the first value is not the largest.




                  That's simply an issue with interpreting the text books the wrong way. There is nothing special about the first sample, and there is no reason at all, why it would have to be the largest. I'm quite sure that none of the text box actually says anything about this.



                  Some very simple "beginner" filters just happen to have this property, so you looked at a bunch of pictures and formed a conclusion & generalization that's neither supported by the text or the math.






                  share|improve this answer






















                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote










                    The impulse response of this filter does not look like most text-book
                    examples in that the first value is not the largest.




                    That's simply an issue with interpreting the text books the wrong way. There is nothing special about the first sample, and there is no reason at all, why it would have to be the largest. I'm quite sure that none of the text box actually says anything about this.



                    Some very simple "beginner" filters just happen to have this property, so you looked at a bunch of pictures and formed a conclusion & generalization that's neither supported by the text or the math.






                    share|improve this answer













                    The impulse response of this filter does not look like most text-book
                    examples in that the first value is not the largest.




                    That's simply an issue with interpreting the text books the wrong way. There is nothing special about the first sample, and there is no reason at all, why it would have to be the largest. I'm quite sure that none of the text box actually says anything about this.



                    Some very simple "beginner" filters just happen to have this property, so you looked at a bunch of pictures and formed a conclusion & generalization that's neither supported by the text or the math.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 3 at 13:54









                    Hilmar

                    9,002916




                    9,002916




















                        up vote
                        1
                        down vote













                        Starting from an FIR filter with an absolutely flat frequency response:




                        • [ 1 0 0 0 0 ] has a delay of one sample,


                        • [ 0 0 1 0 0 ] has a delay of three samples.

                        The largest coefficient corresponds to the filter's group delay. For a lowpass filter like [ 1 -2 7 -2 1] it is the group delay for the DC component — if you look at the step [ 0 0 0 1 1 1 1 1 1 1 ] response [ 0 0 0 1 -1 6 4 5 5 5] it is fairly obvious what the filter's DC delay is. If you design an FIR lowpass filter with uniform group delay for all passband frequencies, it will have a single largest coefficient in the middle bin, while the length of the filter corresponds to the filter's selectivity.



                        The same filter with no delay would be non-causal, as the small coefficients before the large one would have negative indexes.



                        For IIR filters, it's slightly less obvious, because they have two coefficient sets and are unlikely to have flat group delay, but you can still get better stopband attenuation and sharper falloffs with larger delays.






                        share|improve this answer
























                          up vote
                          1
                          down vote













                          Starting from an FIR filter with an absolutely flat frequency response:




                          • [ 1 0 0 0 0 ] has a delay of one sample,


                          • [ 0 0 1 0 0 ] has a delay of three samples.

                          The largest coefficient corresponds to the filter's group delay. For a lowpass filter like [ 1 -2 7 -2 1] it is the group delay for the DC component — if you look at the step [ 0 0 0 1 1 1 1 1 1 1 ] response [ 0 0 0 1 -1 6 4 5 5 5] it is fairly obvious what the filter's DC delay is. If you design an FIR lowpass filter with uniform group delay for all passband frequencies, it will have a single largest coefficient in the middle bin, while the length of the filter corresponds to the filter's selectivity.



                          The same filter with no delay would be non-causal, as the small coefficients before the large one would have negative indexes.



                          For IIR filters, it's slightly less obvious, because they have two coefficient sets and are unlikely to have flat group delay, but you can still get better stopband attenuation and sharper falloffs with larger delays.






                          share|improve this answer






















                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            Starting from an FIR filter with an absolutely flat frequency response:




                            • [ 1 0 0 0 0 ] has a delay of one sample,


                            • [ 0 0 1 0 0 ] has a delay of three samples.

                            The largest coefficient corresponds to the filter's group delay. For a lowpass filter like [ 1 -2 7 -2 1] it is the group delay for the DC component — if you look at the step [ 0 0 0 1 1 1 1 1 1 1 ] response [ 0 0 0 1 -1 6 4 5 5 5] it is fairly obvious what the filter's DC delay is. If you design an FIR lowpass filter with uniform group delay for all passband frequencies, it will have a single largest coefficient in the middle bin, while the length of the filter corresponds to the filter's selectivity.



                            The same filter with no delay would be non-causal, as the small coefficients before the large one would have negative indexes.



                            For IIR filters, it's slightly less obvious, because they have two coefficient sets and are unlikely to have flat group delay, but you can still get better stopband attenuation and sharper falloffs with larger delays.






                            share|improve this answer












                            Starting from an FIR filter with an absolutely flat frequency response:




                            • [ 1 0 0 0 0 ] has a delay of one sample,


                            • [ 0 0 1 0 0 ] has a delay of three samples.

                            The largest coefficient corresponds to the filter's group delay. For a lowpass filter like [ 1 -2 7 -2 1] it is the group delay for the DC component — if you look at the step [ 0 0 0 1 1 1 1 1 1 1 ] response [ 0 0 0 1 -1 6 4 5 5 5] it is fairly obvious what the filter's DC delay is. If you design an FIR lowpass filter with uniform group delay for all passband frequencies, it will have a single largest coefficient in the middle bin, while the length of the filter corresponds to the filter's selectivity.



                            The same filter with no delay would be non-causal, as the small coefficients before the large one would have negative indexes.



                            For IIR filters, it's slightly less obvious, because they have two coefficient sets and are unlikely to have flat group delay, but you can still get better stopband attenuation and sharper falloffs with larger delays.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Sep 3 at 19:06









                            Simon Richter

                            1862




                            1862




















                                up vote
                                0
                                down vote













                                The confusion might arise from what people mean by first order. In some places, like:



                                • SE.DSP: What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?


                                • Tutorial on a very simple yet useful filter: the first order IIR filter, J. Arzi, 2016

                                a first order filter follows the input ($x$)/output ($y$) equation:



                                $$ y[n] = (1-lambda)y[n-1]+lambda x[n],,$$
                                or equivalently in tracking form:
                                $$ y[n] = y[n-1]+lambda (x[n]-y[n-1]),.$$



                                It has numerous names, including first order exponential averaging low-pass filter or exponentially weighted moving average (EWMA). More details are given in



                                • What is the name of these simple filter algorithms?

                                • Is there a technical term for this simple method of smoothing out a signal?

                                In that case, the impulse response $h$ of the filter is explicit. For $k< 0 $, $h[k] = 0$, and for $kge 0 $, $h[k] = lambda(1-lambda)^k$, where $0<lambda < 1$ is a smoothing factor. In this situation, the "first" value $h[0] $ is indeed the largest, since the exponential sequence $lambda(1-lambda)^k$ is decreasing:



                                Impulse responses for exponential first order filters



                                Other filter families are called first order, with additional constraints, like Butterworth's for which Mmatt's answer is complete.






                                share|improve this answer


























                                  up vote
                                  0
                                  down vote













                                  The confusion might arise from what people mean by first order. In some places, like:



                                  • SE.DSP: What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?


                                  • Tutorial on a very simple yet useful filter: the first order IIR filter, J. Arzi, 2016

                                  a first order filter follows the input ($x$)/output ($y$) equation:



                                  $$ y[n] = (1-lambda)y[n-1]+lambda x[n],,$$
                                  or equivalently in tracking form:
                                  $$ y[n] = y[n-1]+lambda (x[n]-y[n-1]),.$$



                                  It has numerous names, including first order exponential averaging low-pass filter or exponentially weighted moving average (EWMA). More details are given in



                                  • What is the name of these simple filter algorithms?

                                  • Is there a technical term for this simple method of smoothing out a signal?

                                  In that case, the impulse response $h$ of the filter is explicit. For $k< 0 $, $h[k] = 0$, and for $kge 0 $, $h[k] = lambda(1-lambda)^k$, where $0<lambda < 1$ is a smoothing factor. In this situation, the "first" value $h[0] $ is indeed the largest, since the exponential sequence $lambda(1-lambda)^k$ is decreasing:



                                  Impulse responses for exponential first order filters



                                  Other filter families are called first order, with additional constraints, like Butterworth's for which Mmatt's answer is complete.






                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    The confusion might arise from what people mean by first order. In some places, like:



                                    • SE.DSP: What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?


                                    • Tutorial on a very simple yet useful filter: the first order IIR filter, J. Arzi, 2016

                                    a first order filter follows the input ($x$)/output ($y$) equation:



                                    $$ y[n] = (1-lambda)y[n-1]+lambda x[n],,$$
                                    or equivalently in tracking form:
                                    $$ y[n] = y[n-1]+lambda (x[n]-y[n-1]),.$$



                                    It has numerous names, including first order exponential averaging low-pass filter or exponentially weighted moving average (EWMA). More details are given in



                                    • What is the name of these simple filter algorithms?

                                    • Is there a technical term for this simple method of smoothing out a signal?

                                    In that case, the impulse response $h$ of the filter is explicit. For $k< 0 $, $h[k] = 0$, and for $kge 0 $, $h[k] = lambda(1-lambda)^k$, where $0<lambda < 1$ is a smoothing factor. In this situation, the "first" value $h[0] $ is indeed the largest, since the exponential sequence $lambda(1-lambda)^k$ is decreasing:



                                    Impulse responses for exponential first order filters



                                    Other filter families are called first order, with additional constraints, like Butterworth's for which Mmatt's answer is complete.






                                    share|improve this answer














                                    The confusion might arise from what people mean by first order. In some places, like:



                                    • SE.DSP: What Is the Best First Order IIR (AR Filter) Approximation to a Moving Average Filter (FIR Filter)?


                                    • Tutorial on a very simple yet useful filter: the first order IIR filter, J. Arzi, 2016

                                    a first order filter follows the input ($x$)/output ($y$) equation:



                                    $$ y[n] = (1-lambda)y[n-1]+lambda x[n],,$$
                                    or equivalently in tracking form:
                                    $$ y[n] = y[n-1]+lambda (x[n]-y[n-1]),.$$



                                    It has numerous names, including first order exponential averaging low-pass filter or exponentially weighted moving average (EWMA). More details are given in



                                    • What is the name of these simple filter algorithms?

                                    • Is there a technical term for this simple method of smoothing out a signal?

                                    In that case, the impulse response $h$ of the filter is explicit. For $k< 0 $, $h[k] = 0$, and for $kge 0 $, $h[k] = lambda(1-lambda)^k$, where $0<lambda < 1$ is a smoothing factor. In this situation, the "first" value $h[0] $ is indeed the largest, since the exponential sequence $lambda(1-lambda)^k$ is decreasing:



                                    Impulse responses for exponential first order filters



                                    Other filter families are called first order, with additional constraints, like Butterworth's for which Mmatt's answer is complete.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Sep 3 at 15:44

























                                    answered Sep 3 at 15:33









                                    Laurent Duval

                                    14.8k31955




                                    14.8k31955



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdsp.stackexchange.com%2fquestions%2f51709%2fwhy-is-the-first-value-in-digital-first-order-iir-filter-impulse-response-not-th%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Comments

                                        Popular posts from this blog

                                        Long meetings (6-7 hours a day): Being “babysat” by supervisor

                                        Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                                        Confectionery