findud<-function(v){ vud<-v[-1]-v[-length(v)] return(ifelse(vud>0,1,-1)) } udcorr <-function(x,y) { ud<-lapply(list(x,y),findud) return(mean(ud[[1]] == ud[[2]])) } diff(u) #差分 sign(diff(u))#将差分转换为-1到1的形式
时间: 2024-09-20 02:16:12
findud<-function(v){ vud<-v[-1]-v[-length(v)] return(ifelse(vud>0,1,-1)) } udcorr <-function(x,y) { ud<-lapply(list(x,y),findud) return(mean(ud[[1]] == ud[[2]])) } diff(u) #差分 sign(diff(u))#将差分转换为-1到1的形式