Skip to content

Instantly share code, notes, and snippets.

@iskandr
Created January 29, 2013 19:36
Show Gist options
  • Save iskandr/4666991 to your computer and use it in GitHub Desktop.
Save iskandr/4666991 to your computer and use it in GitHub Desktop.
@parakeet.jit
def count_thresh(vec, thresh):
"""
Given a vector of values, counts the number of
elements greater, less, or equal to a threshold
"""
n_less = 0
n_greater = 0
n_eq = 0
for elt in vec:
if elt < thresh:
n_less += 1
elif elt > thresh:
n_greater += 1
else:
n_eq += 1
return (n_less, n_greater, n_eq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment