Skip to content

Instantly share code, notes, and snippets.

@FedericoV
Created February 4, 2015 10:36
Show Gist options
  • Save FedericoV/7d08ef6e173f030bb611 to your computer and use it in GitHub Desktop.
Save FedericoV/7d08ef6e173f030bb611 to your computer and use it in GitHub Desktop.
@numba.jit(target='cpu', nopython=True)
def fast_simpson(i, j):
a = 0
b = 0
c = 0
M = i.shape[0]
for idx in range(M):
a += (i[idx] == 1) and (j[idx] == 1)
b += (i[idx] == 1) and (j[idx] == 0)
c += (i[idx] == 0) and (j[idx] == 1)
return 1 - (a / float(min((a + b), (a +c))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment