Statistical Methods

Make Filter Startup Assumptions Reproducible

Define the task

A recursive filter needs an initial state as well as coefficients and input values. Starting from zero and starting from a presumed steady input are different assumptions about the unobserved past. Document which is appropriate before processing a record. SciPy's lfilter_zi constructs a state corresponding to the step-response steady state; it does not recover the actual pre-record signal or remove genuine physiological transients.

Carry out the check

Record the coefficient convention and normalize consistently when the leading denominator coefficient is not one. For a constant-start assumption, scale the unit-step initial state by the first input value, while checking the filter's DC gain. Preserve the final state when processing consecutive chunks of the same uninterrupted record. Resetting the state at each chunk creates repeated startup effects. Separately label acquisition gaps, where carrying state across the gap may also be unjustified.

Worked hypothetical example

Hypothetical example: the unity-gain recurrence y[t]=0.5x[t]+0.5y[t−1] receives constant input 2. With previous output zero, the first outputs are 1,1.5,1.75. With previous output 2, the output stays 2. In the direct-form state convention for b=[0.5] and a=[1,−0.5], the unit-step state is 0.5; scaling it by 2 gives state 1, not previous output 2. Store the actual library state convention, since a recurrence's previous output and a software state vector need not be interchangeable.

Method checked 24 November 2026 against primary documentation: signal.lfilter_zi.

Related reading

Reading path: Analyze data. Guide 220 of 222. Choose any guide to suit your project.

Statistical Methods

Make a Welch power-spectrum estimate reproducible

Report segment, overlap and scaling choices for a power spectrum.

Statistical Methods

Record Boundary Assumptions in Polyphase Resampling

Practical steps and a hypothetical example: Document filtering and boundary assumptions when changing sample rate.

Browse this reading pathTools for this stageGuides and downloads for this stage