Formula for calculating correlation coefficient