\name{Kullback.Leibler}
\alias{Kullback.Leibler}
\title{Multivariate Informationtheoretic Measures}
\description{
  These functions calculate mulivariate informationtheoretic measures: \emph{Kullback Leibler divergence}.
}
\usage{
Kullback.Leibler(p, basis = 2)
}
\arguments{
  \item{p}{ matrix, each column contains probabilities of one distribution across the same alphabet (rows) }
  \item{basis}{ basis of the log used (default=2) }
}
\details{
  \deqn{D_{KL}(P||Q) = \sum(P(x) \dot log \frac{P(x)}{Q(x)})}{D_KL(P||Q) = sum(P*log(P/Q))}
}
\value{
  A square divergence matrix,
  \item{Totals}{always returned: a list with components \emph{H} joint entropy, \emph{Ha} row entropy, \emph{Hab}  row conditional entropy given columns, \emph{Hb} column entropy, \emph{Hba} column conditional entropy given rows, \emph{Im} mutual information }
  \item{Margins}{returned unless grain="Total": \emph{pa} row probabilities , \emph{ha} row entropie, \emph{hab} colwise conditional entropies, \emph{pb} column probabilities, \emph{hb} column entropy , \emph{hba} rowwise conditional entropies}
  \item{Cells}{returned if grain="Cells": \emph{p} joint probabilities, \emph{pab} columnwise conditional probabilities, \emph{pba} rowwise conditional probabilities, \emph{h} joint entropies, \emph{hab} columnwise conditional entropies, \emph{hba} rowwise conditional entropies }
}
\references{ MacKay, David J.C. (2003). \emph{Information Theory, Inference, and Learning Algorithms (chapter 8).} Cambridge University Press.}
\author{ Jens Oehlschlägel }
\seealso{ \code{\link{shannon.information}}, \code{\link[distutil]{dist.entropy}}, \code{\link{Kullback.Leibler}}, \code{\link[base]{log}} }
\examples{
 x <- seq(-3, 3, 0.1)
 cp <- pnorm(x)
 p <- cp[-1] - cp[-length(cp)]
 cq <- punif(x, -3, 3)
 q <- cq[-1] - cq[-length(cq)]
 Kullback.Leibler(cbind(p,q))
}
\keyword{ multivariate }
