11  Covariance and Correlation

\[ Covariance = \frac{1}{N-1}\sum_{i=1}^{N}(x_i-\bar{x})(y_i-\bar{y}) \]

\[ Correlation = \frac{\sum_{i=1}^{N}(x_i-\bar{x})(y_i-\bar{y})}{\sigma_{x}\sigma_{y}} \]

ct <- c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,5,5,6,6,14)
mean_ct <- mean(ct)

vr <- sum((ct-mean_ct)^2)/(length(ct)-1)
sd <- sqrt(vr)