rheon.corr.to_z

rheon.corr.to_z(rho: Any) → Any[source]

Apply Fisher’s transform, z = atanh(rho), to correlations elementwise.

Use it to move correlations to a scale on which their sampling error is about normal, with variance 1 / (n - 3), before you average, difference or test them. from_z() maps back.

Parameters

rho

A correlation, or an array of them. |rho| is clipped at Z_CLIP, 1 - 1e-6, so a degenerate ±1 gives a finite z of about 7.25, where atanh would give inf.

Returns

A float, or a float array of rho’s shape.

Examples

print(rp.corr.to_z([0.0, 0.5, 1.0]).round(3))
[0.    0.549 7.254]

See also

Notes

Because of the clip, the round trip through from_z() is not quite the identity at the ends: it gives back ±Z_CLIP, to rounding, for ±1.