linear_model

Fit a linear system model in a sliding window

pynumdiff.linear_model.lineardiff(x, dt, params=None, options=None, order=None, gamma=None, window_size=None, step_size=10, kernel='friedrichs', solver=None)

Slide a smoothing derivative function across data, with specified window size.

Parameters:
  • x (np.array[float]) – data to differentiate

  • dt (float) – step size

  • params (list[int, float, int]) – (deprecated, prefer order, gamma, and window_size)

  • options (dict) – (deprecated, prefer sliding, step_size, kernel, and solver a dictionary consisting of {‘sliding’: (bool), ‘step_size’: (int), ‘kernel_name’: (str), ‘solver’: (str)}

  • order (int>1) – order of the polynomial

  • gamma (float) – regularization term

  • window_size (int) – size of the sliding window (ignored if not sliding)

  • step_size (int) – step size for sliding

  • kernel (str) – name of kernel to use for weighting and smoothing windows (‘gaussian’ or ‘friedrichs’)

  • solver (str) – CVXPY solver to use, one of cvxpy.installed_solvers()

Returns:

  • x_hat (np.array) – estimated (smoothed) x

  • dxdt_hat (np.array) – estimated derivative of x