Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7054223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:36:02+00:00 2026-05-28T03:36:02+00:00

All – I am trying to use SciPy’s signal.lfilter function to filter a vector

  • 0

All –

I am trying to use SciPy’s signal.lfilter function to filter a vector of samples – unfortunately, all that is returned is a vector of NaN.

I have plotted the frequency response of the filter, and the filter coefficients look correct; I’m fairly certain the issue is with the actual call to lfilter.

It’s a high-pass Chebychev I filter, which I’m creating with:

b,a = signal.iirdesign(wp = 0.11, ws= 0.1, gstop= 60, gpass=1, ftype='cheby1')

I am then filtering data with:

filtered_data = signal.lfilter(b, a, data)

Below, I am printing a selection of 20 samples from the pre-filtered data, and then the filtered data. You can clearly see the issue:

### Printing a small selection of the data before it is filtered:

((-0.003070347011089325+0.0073614344000816345j), (-0.003162827342748642+0.007342938333749771j), (-0.003310795873403549+0.0073614344000816345j), (-0.0031813234090805054+0.007342938333749771j), (-0.003255307674407959+0.007398426532745361j), (-0.003162827342748642+0.007287450134754181j), (-0.003125835210084915+0.007509402930736542j), (-0.003162827342748642+0.007342938333749771j), (-0.0031073391437530518+0.007287450134754181j), (-0.0032368116080760956+0.007398426532745361j), (-0.0030888430774211884+0.007342938333749771j))


### Printing a small selection of the filtered data:

[ nan nanj  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj
  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj
  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj  nan nanj]

Like I said before, the coefficients of the filter look good. They are:

b = [  4.06886235e-02  -7.73083846e-01   6.95775461e+00  -3.94272761e+01
   1.57709105e+02  -4.73127314e+02   1.10396373e+03  -2.05021836e+03
   3.07532754e+03  -3.75873366e+03   3.75873366e+03  -3.07532754e+03
   2.05021836e+03  -1.10396373e+03   4.73127314e+02  -1.57709105e+02
   3.94272761e+01  -6.95775461e+00   7.73083846e-01  -4.06886235e-02]
a = [  1.00000000e+00  -1.27730099e+01   7.81201390e+01  -3.03738394e+02
   8.40827723e+02  -1.75902089e+03   2.88045462e+03  -3.77173152e+03
   3.99609428e+03  -3.43732844e+03   2.38415171e+03  -1.30118368e+03
   5.21654119e+02  -1.18026566e+02  -1.85597824e+01   3.24205235e+01
  -1.65545917e+01   5.02665439e+00  -9.09697811e-01   7.68172820e-02]

So why would lfilter return only NaN? How am I using this function incorrectly?

Thanks in advance for your help!

Edit:

Okay, I solved it.

For anyone that encounters this in the future:

For whatever reason, even though the returned coefficients for the filter looked good, when I then used those coefficients in SciPy’s lfilter function, the filtered values were unbounded. Simply changing the passband edge to ANY number other than 0.11 fixed the problem. Even this works:

b,a = signal.iirdesign(wp = 0.119, ws= 0.1, gstop= 60, gpass=1, ftype='cheby1')

Other than manually grepping through the poles and zeros of the filter, I’m not sure how you would detect instability of the filter. Bizarre.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:36:03+00:00Added an answer on May 28, 2026 at 3:36 am

    An IIR filter is stable if the absolute values of the roots of the denominator of the discrete transfer function a(z) are all less than one. So, you can detect the instability by following code:

    from scipy import signal
    import numpy as np
    b1, a1 = signal.iirdesign(wp = 0.11, ws= 0.1, gstop= 60, gpass=1, ftype='cheby1')
    b2, a2 = signal.iirdesign(wp = 0.119, ws= 0.1, gstop= 60, gpass=1, ftype='cheby1')
    
    print "filter1", np.all(np.abs(np.roots(a1))<1)
    print "filter2", np.all(np.abs(np.roots(a2))<1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I'm trying to use vlookup in a simple VBA function, but it is
all, I am trying to multiply a matrix to a vector in OpenGL, but
All, I'm trying to use the jQuery Form Validator (http://docs.jquery.com/Plugins/Validation). However I'd like to
All I am trying to create an app that start capturing the video from
All, I have my application setup so that i can use a specific username
All, I'm trying to use the jQuery File Upload Demo: http://blueimp.github.com/jQuery-File-Upload/ My question is
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
All, I currently have two projects that are under SourceSafe that I am unable
All the guys probably will recommend that I read the follow previously question in
All, See the code below: function menu() { this.menuitem=[]; this.submenu=[]; this.menuitem[0] = $('div#sivname1'); this.menuitem[1]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.