Created
January 29, 2013 19:36
-
-
Save iskandr/4666991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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