www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CompareKendallAndSpearmanRankCorrelationCoefficientsExample.m
%% Compare Kendall and Spearman Rank Correlation Coefficients % % Copyright 2015 The MathWorks, Inc. %% Plot comparison rho = -1:.01:1; tau = 2.*asin(rho)./pi; rho_s = 6.*asin(rho./2)./pi; plot(rho,tau,'b-','LineWidth',2) hold on plot(rho,rho_s,'g-','LineWidth',2) plot([-1 1],[-1 1],'k:','LineWidth',2) axis([-1 1 -1 1]) xlabel('rho') ylabel('Rank correlation coefficient') legend('Kendall''s {\it\tau}', ... 'Spearman''s {\it\rho_s}', ... 'location','NW')