草薙の研究ログ

英語の先生をやってます。

RでKendall距離,Hamming距離,Cayley距離,Ulam距離

順序間の距離を表す,(編集型の)上記の距離をRでもとめる。PerMallowsパッケージというのを使う。

library(PerMallows)
x<-c(1,2,3,4,5,6,7,8,9,10)
y<-c(2,1,3,4,6,5,7,9,8,10)
distance(x,y,"Kendall")
distance(x,y,"Hamming")
distance(x,y,"Cayley")
distance(x,y,"Ulam")