Skip to content

Different output values using IirFilter's filtfilt when input is an array of same points #29

@willtai

Description

@willtai

Hey all, I've recently discovered fili.js and I think it's great work. I have a question regarding the result of this simple case, where the input array to IirFilter's filtfilt function is the array [ 100, 100, 100, 100, 100 ], I would expect the output to also be [ 100, 100, 100, 100, 100 ], but I get [ 65.46938196547178, 95.22394297908647, 112.04622657462305, 109.39208161544768, 88.16201291845088 ]. Perhaps I am misunderstanding how this function is used? I expected [ 100, 100, 100, 100, 100 ] because I got this result using Python's scipy. I am using coefficients for a butterworth filter such as below.

var CalcCascades = require('./src/calcCascades')
var IirFilter = require('./src/iirFilter')
var iirCascadeCalculator;
iirCascadeCalculator = new CalcCascades()

const inputArray = [100, 100, 100, 100, 100]
function filterData() {
    var iirCascadeCalculator, filterCoeffs, filter
    iirCascadeCalculator = new CalcCascades()
    filterCoeffs = iirCascadeCalculator.lowpass({
        order: 3,
        characteristic: 'butterworth',
        Fs: 1 / (37 * ( 10 ** -6 )),
        Fc: 4000
      });
      filter = new IirFilter(filterCoeffs);
      console.log(filter.filtfilt(inputArray));
}

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions