blob: 864f3979043031d43061e32e3ad1a9032ab37493 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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}"
}
|