polars_online.corr.absorption_shift

polars_online.corr.absorption_shift(ar_fast: Any, ar_slow: Any, *, scale: float | None = None) → Any[source]

Compute Kritzman, Li, Page and Rigobon’s standardized absorption shift.

Use it to flag a rise in how much the series move as one: a fast absorption ratio against a slow one, in units of the slow one’s spread. Compute each ratio with absorption() over windows of your choice.

Parameters

ar_fast, ar_slow

Two series of absorption ratios aligned row by row, the first over a short window and the second over a long one.

scale

The divisor. Default None, the population standard deviation of ar_slow over the sample (dividing by the number of rows).

Returns

A float array, (ar_fast - ar_slow) / scale elementwise, or nan throughout where scale is not above 0.

Raises

ValueError

ar_fast and ar_slow of different shapes.

Examples

fast = np.array([0.60, 0.62, 0.70, 0.80])
slow = np.array([0.60, 0.61, 0.63, 0.66])
print(po.corr.absorption_shift(fast, slow).round(2))
[0.   0.44 3.06 6.11]

See also

Notes

The function’s older name, shift, is refused, and the error names this one: Polars uses shift for a lag.