Skip to content
This repository was archived by the owner on Mar 17, 2023. It is now read-only.
This repository was archived by the owner on Mar 17, 2023. It is now read-only.

A lightweight implementation that dramatically improves runtime of xicor #17

@atarashansky

Description

@atarashansky

Hello, I wrote a lightweight (and much faster) implementation of the xi correlation metric.

In my tests, this implementation is > 300x faster than the current implementation.

import numpy as np

def _xicorr(X,Y):
    n = X.size
    xi = np.argsort(X,kind='quicksort')
    Y = Y[xi]
    _,b,c = np.unique(Y,return_counts=True,return_inverse=True)
    r = np.cumsum(c)[b]
    _,b,c = np.unique(-Y,return_counts=True,return_inverse=True)
    l = np.cumsum(c)[b]
    return 1 - n*np.abs(np.diff(r)).sum() / (2*(l*(n-l)).sum())

Hopefully this is helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions