Skip to content

Commit

Permalink
No more nil handling for TVD.
Browse files Browse the repository at this point in the history
  • Loading branch information
evansenter committed Jun 26, 2012
1 parent 4d59d65 commit 9d91643
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/diverge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def jensen_shannon
alias :js :jensen_shannon

def total_variation_distance
0.5 * p.zip(q).inject(0.0) { |sum, (i, j)| sum + ((i || 0) - (j || 0)).abs }
0.5 * p.zip(q).inject(0.0) { |sum, (i, j)| sum + (i - j).abs }
end

alias :tvd :total_variation_distance
Expand Down

0 comments on commit 9d91643

Please sign in to comment.