nispace.stats.coloc.corr
- nispace.stats.coloc.corr(x, y, rank=False)[source]
Compute Pearson (or, with rank=True, Spearman) correlation for two 1D arrays.
- Parameters:
x (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be plain 1D
np.ndarrayinstances of equal length. Does not handle NaN – strip/mask NaN entries before calling.y (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be plain 1D
np.ndarrayinstances of equal length. Does not handle NaN – strip/mask NaN entries before calling.rank (bool, default False) – If True, rank x/y via rank1d first (Spearman); if False, compute Pearson directly on the raw values.
- Returns:
r – NaN if either array has zero variance.
- Return type:
float
Notes
A more generic rank-optional sibling of pearson; used by nulls.py and stats/autocorr.py for spatial-autocorrelation-null comparisons. core/colocalize.py’s own pearson/spearman colocalization path calls rank2d + plain pearson instead of this function.