Skip to content

asymcat.correlation

Association between two whole variables, given as aligned series. See Summarise whole variables.

Convenience wrappers for computing association measures on parallel series.

Unlike asymcat.scorer.CatScorer, which returns per-symbol-pair directional scores from a list of co-occurrences, the helpers in this module operate on two aligned series (series_x and series_y) and return a single summary statistic for the pair of variables.

Note that not every measure here is symmetric: cramers_v is symmetric by definition, whereas conditional_entropy and theil_u are directional (x given y) and are therefore, in general, asymmetric.

cramers_v

cramers_v(series_x, series_y)

Compute Cramér's V between two aligned series.

Cramér's V is a symmetric measure of association derived from Pearson's chi-square statistic, ranging from 0 (no association) to 1 (perfect association).

Parameters:

Name Type Description Default
series_x list

The first series of observed symbols.

required
series_y list

The second series of observed symbols, aligned with series_x.

required

Returns:

Type Description
float

Cramér's V for the two series.

conditional_entropy

conditional_entropy(series_x, series_y, estimator='plugin')

Compute the conditional entropy of series_x given series_y.

This is a directional measure: in general, H(x|y) != H(y|x).

Parameters:

Name Type Description Default
series_x list

The series whose entropy (conditioned on series_y) is computed.

required
series_y list

The conditioning series, aligned with series_x.

required
estimator str

Entropy estimator: "plugin" (default), "chao_shen" or "nsb"; see asymcat.scorer.conditional_entropy.

'plugin'

Returns:

Type Description
float

The conditional entropy H(x|y).

theil_u

theil_u(series_x, series_y, estimator='plugin')

Compute Theil's U (uncertainty coefficient) of series_x given series_y.

Theil's U normalizes the reduction in uncertainty of series_x obtained from knowing series_y by the entropy of series_x, yielding a value in the [0, 1] range. It is a directional measure and is, in general, asymmetric (U(x|y) != U(y|x)).

Parameters:

Name Type Description Default
series_x list

The series whose uncertainty is being reduced.

required
series_y list

The conditioning series, aligned with series_x.

required
estimator str

Entropy estimator: "plugin" (default), "chao_shen" or "nsb"; see asymcat.scorer.compute_theil_u. Bias-corrected estimates are not confined to [0, 1].

'plugin'

Returns:

Type Description
float

Theil's U for series_x given series_y, in [0, 1] for the plug-in estimator.