x <- matrix(c(1, 2, 3, 3, 2, 1, 5, 2, 3, 9, 8, 7), ncol = 3, nrow = 4)
MHI(x)
#> [1] 0.4166667 0.5833333 0.9166667 0.7500000
y <- array(c(1, 2, 3, 3, 2, 1, 5, 2, 3, 9, 8, 7, -1, -5, -6, 2, 3, 0, -1, 0, 2, -1, -2, 0),
dim = c(3, 4, 2)
)
MHI(y)
#> [1] 0.5000000 0.4166667 0.4166667