start
authortomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 12:44:05 +0000 (13:44 +0100)
committertomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 12:44:05 +0000 (13:44 +0100)
filesizes.py [new file with mode: 0755]
notes [new file with mode: 0644]
weights.py [new file with mode: 0755]

diff --git a/filesizes.py b/filesizes.py
new file mode 100755 (executable)
index 0000000..893432e
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+# File sizes: histogram of file sizes
+
+import sys
+import os
+from pathlib import Path
+import matplotlib.pyplot as plot
+
+if len(sys.argv) != 2:
+  print(f"Usage: {sys.argv[0]} <directory>\n")
+  exit(1)
+
+def collectdir(direc):
+  sizes = []
+  if not direc.is_dir():
+    print(f"{direc} is not a directory!")
+    exit(1)
+
+  for it in direc.iterdir():
+    if os.access(it, os.R_OK): # ignore otherwise
+      if it.is_file():
+        sizes += [it.stat().st_size]
+      elif it.is_dir():
+        sizes += collectdir(it)
+
+  return sizes
+
+plot.hist(collectdir(Path(sys.argv[1])), 100)
+plot.show()
+
+# plot.hist(weights, 8, facecolor='blue')
+# plot.show()
diff --git a/notes b/notes
new file mode 100644 (file)
index 0000000..f4f9c36
--- /dev/null
+++ b/notes
@@ -0,0 +1,2 @@
+# -*- mode: org -*-
+#+title: histograms
diff --git a/weights.py b/weights.py
new file mode 100755 (executable)
index 0000000..04a9180
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/python3
+# Small extract from http://wiki.stat.ucla.edu/socr/index.php/SOCR_Data_MLB_HeightsWeights
+# (body weights of baseball players)
+# (only the weights in pounds, only the first 80)
+
+import matplotlib.pyplot as plot
+
+weights=[
+  180, 215, 210, 210, 188, 176, 209, 200, 231, 180,
+  188, 180, 185, 160, 180, 185, 197, 189, 185, 219,
+  230, 205, 230, 195, 180, 192, 225, 203, 195, 182,
+  188, 200, 180, 200, 200, 245, 240, 215, 185, 175,
+  199, 200, 215, 200, 205, 206, 186, 188, 220, 210,
+  195, 244, 195, 200, 200, 212, 224, 210, 205, 220,
+  195, 200, 260, 228, 270, 200, 210, 190, 220, 180,
+  205, 210, 220, 211, 200, 180, 190, 170, 230, 155]
+
+plot.hist(weights, 8, facecolor='blue')
+plot.show()