summaryrefslogtreecommitdiff
path: root/dtrain/binning.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-12-06 11:19:50 +0100
committerPatrick Simianer <p@simianer.de>2011-12-06 11:19:50 +0100
commitd3f0e5e833dcc26c98f6bc8583ddc9fa9a4ea0bc (patch)
treeba31a1e5a8b44ff22aa2145c74fbb1a7b5523f6c /dtrain/binning.rb
parent0f9024d49f7622d1c135aa2e3f9ddc6bc4349fb9 (diff)
stuff
Diffstat (limited to 'dtrain/binning.rb')
-rwxr-xr-xdtrain/binning.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/dtrain/binning.rb b/dtrain/binning.rb
new file mode 100755
index 00000000..674f3246
--- /dev/null
+++ b/dtrain/binning.rb
@@ -0,0 +1,35 @@
+bins = []
+bin_sz = 0
+1.upto(3).each { |i|
+ bin_sz = STDIN.gets.strip.split(",")[1].to_i
+ bins.push [[i], bin_sz]
+}
+
+cur_bin = []
+cur_bin_sz = 0
+while line = STDIN.gets
+ count, countcount = line.strip.split ","
+ count = count.to_i
+ countcount = countcount.to_i
+ if (cur_bin_sz + countcount) > bin_sz
+ bins.push [cur_bin, cur_bin_sz]
+ cur_bin = []
+ cur_bin_sz = countcount
+ else
+ cur_bin.push count
+ cur_bin_sz += countcount
+ end
+end
+bins.push [cur_bin, cur_bin_sz]
+
+c = 0
+e = 0
+bins.each { |i|
+ puts "#{e} | #{i[0].size}: #{i[0][0]}.. #{i[1]}" if i[0].size > 0
+ c += 1 if i[0].size > 0
+ e += 1
+}
+puts "#{c} bins (#{bins.size})"
+puts "bin sz #{bin_sz}"
+
+