Pearson Correlation Coefficient Formula Understanding As part of a program I'm writing I need to use the Pearson Correlation Coefficient. However I'm getting incorrect results. 
Here is the formula I'm using:
$$ \rho_{X, Y} = \frac{\frac{1}{n}\sum_{i = 1}^{i = n}(x_i - \mu_X)(y_i - \mu_Y)}{\sigma_X\sigma_Y} $$
Specifically, I'm not sure if I'm getting the $\frac{1}{n}$ part correct in the numerator. Does this mean I need to multiply the whole sum by $\frac{1}{n}$ or is it just some notation for the sum.
Any help would be appreciated.
 A: It means multiply the whole sum by $\dfrac 1 n$.
\begin{align}
\rho_{X,Y} & = \frac{\frac 1 n \sum_{i=1}^n (x_i - \operatorname{mean}(X))(y_i - \operatorname{mean}(Y))}{\sigma_X \cdot \sigma_Y} \\[15pt]
& = \frac{\frac 1 n \sum_{i=1}^n (x_i - \operatorname{mean}(X))(y_i - \operatorname{mean}(Y))}{\sqrt{\left(\frac1 n\sum_{i=1}^n (x_i - \operatorname{mean}(X))^2\right) \left(\frac1 n\sum_{i=1}^n (y_i - \operatorname{mean}(Y))^2\right)}} \tag 2 \\[15pt]
& = \frac{ \sum_{i=1}^n (x_i - \operatorname{mean}(X))(y_i - \operatorname{mean}(Y))}{\sqrt{\left(\sum_{i=1}^n (x_i - \operatorname{mean}(X))^2\right) \left(\sum_{i=1}^n (y_i - \operatorname{mean}(Y))^2\right)}} \tag 3
\end{align}
When one multiplies that whole sum by $\dfrac 1 n$, then the $\dfrac 1 n$ cancels the $\dfrac 1 n$ that appears in the definitions of $\sigma_X$ and $\sigma_Y$ seen in line $(2)$ above in the denominator.  Thus $\rho_{X,Y}$ can be written without the $\dfrac 1 n$, just as on line $(3)$ above.  It needs to be there because $\sigma_X$ and $\sigma_Y$ are defined as seen on line $(2)$ above, which includes $\dfrac 1 n$.
Often one sees the notation $\bar x = \dfrac {x_1+\cdots+x_n} n$ rather than $\operatorname{mean}(X)$.
Sometimes one seems the notation
$$
s^2_X = \frac 1 {n-1} \sum_{i=1}^n (x_i - \bar x)^2
$$
using $n-1$ rather than $n$.  That is properly done ONLY when $s^2_X$ is an estimate based on a random sample, of the variance of population, when one cannot observe the whole population.  If one somehow knew the popuation mean $\mu_X$ rather than using the sample mean $\bar X = \operatorname{mean}(X) = \dfrac{x_1+\cdots+x_n} n$, then one would put $\mu_X$ in place of $\bar X = \operatorname{mean}(X)$ above, and then the rationale for using $n-1$ instead of $n$ would vanish even if it's only a small sample of size $n$ drawn from a large population.
A: You should be multiplying the entire numerator by $\frac{1}{n}$, because the numerator is an expectation; namely, the expected value of the product of deviations of $X$ and $Y$ from their respective means $\mu_X$ and $\mu_Y$.
