Skip to content

Commit

Permalink
#298: add simple tool to print summary stats about vectors from float…
Browse files Browse the repository at this point in the history
…32 packed file
  • Loading branch information
mikemccand committed Sep 16, 2024
1 parent a7a80b0 commit e40cef5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/python/mikes_tiny_vector_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
import numpy as np

def calculate_statistics(file):
np_array = np.fromfile(file, dtype=np.float32)
percentiles = [1, 10, 50, 90, 99, 100]
for percentile in percentiles:
print(percentile, "Percentile = ", np.percentile(np_array, percentile))
print("average: " + str(np.average(np_array)))
print("stddev: " + str(np.std(np_array)))
print("min .. max: " + str(np.min(np_array)) + " .. " + str(np.max(np_array)))

if __name__ == '__main__':
with open(sys.argv[1], "rb") as inp:
calculate_statistics(inp)

0 comments on commit e40cef5

Please sign in to comment.