redflag.independence module#

Functions related to understanding row independence.

redflag.independence.is_correlated(a: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], n: int = 20, s: int = 20, threshold: float = 0.1) bool#

Check if a dataset is correlated. Uses s chunks of n samples.

Parameters:
  • a (array) – The data.

  • n (int) – The number of samples per chunk.

  • s (int) – The number of chunks.

  • threshold (float) – The auto-correlation threshold.

Returns:

True if the data are correlated.

Return type:

bool

Examples

>>> is_correlated([7, 1, 6, 8, 7, 6, 2, 9, 4, 2])
False
>>> is_correlated([1, 2, 1, 7, 6, 8, 6, 2, 1, 1])
True