Module: Octo::KLDivergence

Included in:
Trendable
Defined in:
lib/octocore/kldivergence.rb

Instance Method Summary collapse

Instance Method Details

#kl_divergence(p, q) ⇒ Float

Calculates the KL-Divergance of two probabilities en.wikipedia.org/wiki/Kullback–Leibler_divergence



10
11
12
# File 'lib/octocore/kldivergence.rb', line 10

def kl_divergence(p, q)
  p * Math.log(p/q)
end