diverge 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/diverge.rb +6 -0
  2. metadata +2 -2
data/lib/diverge.rb CHANGED
@@ -34,4 +34,10 @@ class Diverge
34
34
  end
35
35
 
36
36
  alias :js :jensen_shannon
37
+
38
+ def total_variation_distance
39
+ 0.5 * p.zip(q).inject(0.0) { |sum, (i, j)| sum + ((i || 0) - (j || 0)).abs }
40
+ end
41
+
42
+ alias :tvd, :total_variation_distance
37
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diverge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple collection of functions for determining the divergence between
15
15
  two distributions.