User talk:RyanCMarcus

Your changes to the formula of covariance for discrete variables
Hi,

In this edit you changed the formula of covariance for discrete variables to:

$$\operatorname{cov} (X,Y)=\frac{1}{nk}\sum_{i=1}^n \sum_{j=1}^k (x_i-E(X))(y_j-E(Y))$$

However, if you look at that formula, both $$x_i$$ and $$E(X)$$ are constant in the inner sum on $$j$$ and the term can be moved outside of it. After that, the whole inner sum on $$j$$ with only $$y_j$$ and $$E(Y)$$ left is constant with regard to the outer sum on $$i$$ and can be moved outside of it. Now you have two independent sums, both of the form:

$$\frac{1}{n}\sum_{i=1}^n (x_i-E(X))$$

This can be split into two sums, where the second one has a constant and the first one is equal to the mean of $$X$$, namely $$E(X)$$:

$$\frac{1}{n}\sum_{i=1}^n x_i - \frac{1}{n}\sum_{i=1}^n E(X) = \frac{1}{n}\sum_{i=1}^n x_i - E(X) = E(X) - E(X) = 0$$

If you doubt some step of the above, feel free to calculate the covariance for something using your modified formula - you'll always get 0. :)

I think you might've been confused by the example below - it really doesn't belong in the same section, IMHO, at least without a bit of accompanying explanation. AFAIK covariance - when calculated for measurements - is always calculated for matching amounts of measurements. The first and second formula are used with $$X = [x_1, x_2, \dots, x_n]$$ and $$Y = [y_1, y_2, \dots, y_n]$$, whereas the example uses a different formula, which is used with a joint probability mass function $$f(x,y)$$. AFAICS the given example joint probability mass function would correspond to eg. $$X = [1, 1, 2, 2]$$ and $$Y = [1, 2, 2, 3]$$ - that is each $$f(x, y)$$ gives the probability that for some $$i$$, $$x_i = x$$ and $$y_i = y$$.

I'm not a huge math/statistics person, so of course I might be missing something, but I *did* show the formula along with the reasoning to more math-y people, and they agreed that it simplifies to constant 0. The original formula is also what is used elsewhere, it agrees with the second formula, and I couldn't find your version anywhere else.

So, I've reverted the edit - just thought I'd let you know. (If not for anything else, just in case you used the modified formula somewhere that should be fixed :)

PS. I'll try to poke some more math-y people about clarifying the difference between the formulas and the example in the near future.

Alexerion (talk) 21:32, 28 August 2017 (UTC)