\HeaderA{MI}{Calculate Mutual Information}{MI}
\keyword{methods}{MI}
\begin{Description}\relax
Function to calculate the mutual information of 2 random variables, or
between all pairs of rows of a numerical matrix.
\end{Description}
\begin{Usage}
\begin{verbatim}
MI(x, y=NULL, k=1)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] numerical matrix to calculate the MI between all pairs of
rows from \code{x}. Also, \code{x} must be a numerical vector and
\code{y} must be specified as another numerical vector of same
lenght as \code{x} and the MI value between both them are calculated.
\item[\code{y}] optional numerical vector that must be specified if \code{x}
is a vector. Defaults to NULL.
\item[\code{k}] integer specifying the number of the neighbours to be used in the
calculation of the MI value.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function implements an algorithm proposed by Kraskov et
al. (2004) that don't use estimator of the entropy.
\end{Details}
\begin{Value}
If \code{x} is a matrix, the function return a square matrix with
lenght equal to the number of rows of \code{x} with MI values between
all pairs of rows from \code{x}. If \code{x} is a numerical vector,
\code{y} must be specified and the function returns a positive real
number with the MI value between the two vectors.
\end{Value}
\begin{Author}\relax
Gustavo H. Esteves <\email{gesteves@vision.ime.usp.br}>
\end{Author}
\begin{References}\relax
Kraskov, A.; Stogbauer, H. and Grassberger, P. Estimating mutual
information, \bold{Physical Review E}, 69, 066138, 2004 (\url{http://scitation.aip.org/getabs/servlet/GetabsServlet?prog=normal\&id=PLEEE8000069000006066138000001\&idtype=cvips\&gifs=yes}).
\end{References}
\begin{Examples}
\begin{ExampleCode}
x <- runif(50, 0, 1)
y <- rbeta(50, 1, 2)
MI(x, y)

z <- matrix(rnorm(100, 0, 1), 4, 25)
MI(z)
\end{ExampleCode}
\end{Examples}

