1  | mutualinfo(vec1, vec2)
 | 
vec1 | 
|
vec2 | 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  | ##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
## The function is currently defined as
function (vec1, vec2) 
{
    vec1 <- round(as.numeric(vec1))
    vec2 <- round(as.numeric(vec2))
    m <- length(vec1)
    n <- length(vec2)
    if (m != n) {
        print("the two input vector length differ")
        return(0)
    }
    else {
        vec <- paste(vec1, vec2)
        freq1 <- estpab(vec1)
        freq2 <- estpab(vec2)
        freq12 <- estjointpab(vec1, vec2)
        n1 <- nrow(freq1)
        n2 <- nrow(freq2)
        mutuinfo = 0
        for (i in 1:n1) {
            for (j in 1:n2) {
                temploc = which(freq12 == paste(freq1[i, 1], 
                  freq2[j, 1]))
                if (sum(temploc)) {
                  temp = freq12[temploc, 2] * log(freq12[temploc, 
                    2]/freq1[i, 2]/freq2[j, 2])
                  mutuinfo = mutuinfo + temp
                }
                else {
                  next
                }
            }
        }
        return(mutuinfo/log(2))
    }
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.