等级相关系数 Coefficient Of Rank Correlation

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

puts "Enter Number of Data Set"
n=gets.chomp
n=n.to_f
sum_d=0
i=0
while i<n
 i=i+1
 puts "For Set "+i.to_s
 puts "Rank of Group 1"
 r1=gets.chomp
 r1=r1.to_f
 puts "Rank of Group 2"
 r2=gets.chomp
 r2=r2.to_f
 diff=r1-r2
 d=diff**2
 sum_d=sum_d+d
end

r=1-(6*sum_d)/(n*(n**2-1))
puts "Coefficient of Rank Correlation "+r.to_s