ml4gw.transforms.pearson

Classes

ShiftedPearsonCorrelation(max_shift)

Compute the Pearson correlation for two equal-length timeseries over a pre-defined number of time shifts in each direction.

class ml4gw.transforms.pearson.ShiftedPearsonCorrelation(max_shift)

Bases: Module

Compute the Pearson correlation for two equal-length timeseries over a pre-defined number of time shifts in each direction. Useful for when you want a correlation, but not over every possible shift (i.e. a convolution).

The number of dimensions of the second timeseries y passed at call time should always be less than or equal to the number of dimensions of the first timeseries x, and each dimension should match the corresponding one of x in reverse order (i.e. if x has shape (B, C, T) then y should either have shape (T,), (C, T), or (B, C, T)).

Note that no windowing to either timeseries is applied at call time. Users should do any requisite windowing beforehand.

TODOs: - Should we perform windowing? - Should we support stride > 1?

Parameters:

max_shift (int) -- The maximum number of 1-step time shifts in each direction over which to compute the Pearson coefficient. Output shape will then be (2 * max_shifts + 1, B, C).

forward(x, y)
Return type:

']

Parameters:
  • x (Float[Tensor, 'time'] | Float[Tensor, 'channel time'] | Float[Tensor, 'batch channel time'])

  • y (Float[Tensor, 'time'] | Float[Tensor, 'channel time'] | Float[Tensor, 'batch channel time'])