Skip to content

Commit

Permalink
Diverge.new(..., ...).corr
Browse files Browse the repository at this point in the history
  • Loading branch information
evansenter committed Aug 17, 2012
1 parent f82a910 commit 6c9c65f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.ps
*.gem
.DS_Store
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
gem uninstall diverge --ignore-dependencies
gem build diverge.gemspec && gem install diverge --no-rdoc --no-ri --ignore-dependencies && ruby -e "require 'diverge'"
4 changes: 3 additions & 1 deletion diverge.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Gem::Specification.new do |spec|
spec.name = "diverge"
spec.version = "1.0.4"
spec.version = "1.1.0"
spec.summary = "Distribution divergences."
spec.description = "A simple collection of functions for determining the divergence between two distributions."
spec.authors = ["Evan Senter"]
spec.email = "[email protected]"
spec.files = Dir["{lib}/**/*.rb", "bin/*", "LICENSE", "*.md"]
spec.homepage = "http://rubygems.org/gems/diverge"

spec.add_dependency("gsl", [">= 1.14.0"])
end
8 changes: 8 additions & 0 deletions lib/diverge.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "gsl"

class Diverge
attr_reader :p, :q

Expand Down Expand Up @@ -40,4 +42,10 @@ def total_variation_distance
end

alias :tvd :total_variation_distance

def correlation
GSL::Stats::correlation(GSL::Vector.alloc(p), GSL::Vector.alloc(q))
end

alias :corr :correlation
end

0 comments on commit 6c9c65f

Please sign in to comment.