diff options
-rwxr-xr-x | util/convlr.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/util/convlr.rb b/util/convlr.rb new file mode 100755 index 0000000..864f397 --- /dev/null +++ b/util/convlr.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby + +require 'zipf' + +updates = SparseVector.new +ReadFile.readlines_strip(ARGV[0]).each { |line| + k,v = line.split + updates[k] = v.to_f +} +grads = SparseVector.new +ReadFile.readlines_strip(ARGV[1]).each { |line| + k,v = line.split + grads[k] = v.to_f +} + +smooth = 0.000001 + +ks = updates.keys + grads.keys + +rates = SparseVector.new +ks.each { |k| + rates[k] = -1*(Math.sqrt(updates[k]+smooth)/Math.sqrt(grads[k]+smooth)) +} + +rates.each { |k,v| + puts "#{k} #{v}" +} + |