Skip to content

Instantly share code, notes, and snippets.

@reimai
Last active March 23, 2016 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reimai/482f26f6a0abc25996b9 to your computer and use it in GitHub Desktop.
Save reimai/482f26f6a0abc25996b9 to your computer and use it in GitHub Desktop.
# usage:
# $ sudo apt-get install python-numpy
# $ python percentile.py 95 97 99 99.9 < my_file_with_floats
import numpy as np
import fileinput
import sys
lines = []
for line in sys.stdin:
lines.append(float(line[:-1]))
a = np.array(lines)
for p in sys.argv[1:]:
print "{}: {}".format(p, np.percentile(a, float(p)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment