--- /dev/null
+#!/bin/bash
+#
+
+# Collects and counts the output of multiple invocations over the same input stream.
+# Counts ought to be roughly the same, based on quality of random source.
+
+invoke_n() {
+ seq $1 | ./reservoir_sample -r /dev/random 2>/dev/null
+}
+
+invoke_n_i() {
+ local i=0
+ while [ $i -lt $2 ]
+ do
+ invoke_n $1
+ ((i++))
+ local note=`expr $i % 1000`
+ if [ $note -eq 0 ]
+ then
+ echo "... iteration $i of $2" 1>&2
+ fi
+ done
+}
+
+tally_n_i() {
+ invoke_n_i $1 $2 | sort -n | uniq -c
+}
+
+tally_n_i 20 10000