Skip to content

Instantly share code, notes, and snippets.

@tycho
Created May 16, 2016 16:53
Show Gist options
  • Save tycho/14350316d428d4b622ad028481565ccb to your computer and use it in GitHub Desktop.
Save tycho/14350316d428d4b622ad028481565ccb to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
import fileinput
values = []
for line in fileinput.input():
values.append(float(line.rstrip()))
values.sort()
tps = [ 0.0, 0.50, 0.75, 0.90, 0.95, 0.99, 1.00 ]
for tp in tps:
index = int((len(values) - 1) * tp)
print " P %6.2f: %15.3f" % (tp * 100.0, values[index])
print " N: %15d" % (len(values))
e = sum(values)
print " Sum: %15.3f" % (e)
avg = e / float(len(values))
print " Avg: %15.3f" % (avg)
dif = [ (v - avg) ** 2.0 for v in values ]
var = sum(dif) / float(len(dif))
print " Var: %15.3f" % (var)
print " Std: %15.3f" % (var ** 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment