Added a more general function to compute mutual information