Created
February 13, 2014 17:37
-
-
Save tukachev/8980005 to your computer and use it in GitHub Desktop.
# The Gower similarity index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Gower similarity index | |
gower <- function(p1, p2, max, min){ | |
if (length(p1) != length(p2)) | |
stop("'p1' and 'p2' must have the same length") | |
k <- length(p1) | |
range <- max - min | |
d <- sum(abs(p1 - p2) / range) | |
gs <- 1 - d / k | |
return(gs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment