tsdive.switchback.lag_response
¶
lag_response(
u: ndarray, times: ndarray, tau: float
) -> np.ndarray
First-order lag response to the per-sample setting u, starting from 0.
Over the gap dt from the previous sample the response moves
1 - exp(-dt / tau) of the way to the sample's setting; the first sample
follows a gap of one time unit. tau 0 returns u. Runs of equal
setting are solved in closed form, so the loop runs once per switch.
Examples:
>>> import numpy as np
>>> from tsdive.switchback import lag_response
>>> u = np.array([0.0, 1.0, 1.0, 1.0])
>>> lag_response(u, np.array([0.0, 1.0, 2.0, 3.0]), tau=1.0).round(3).tolist()
[0.0, 0.632, 0.865, 0.95]