r/learndatascience • • 29d ago

Question why do we square deviations for variance instead of just taking absolute values

i keep running into this when explaining spread to people. mean absolute deviation feels like the obvious thing to do, it's literally the average distance from the mean. squaring seems like an arbitrary extra step.

i know squares are easier to differentiate and that variance adds up nicely for independent variables, but i'm not sure that's the real reason it became the default. is there a more intuitive way you explain it, or is it mostly just that the math works out cleaner?

40 Upvotes

33 comments sorted by

13

u/FancyEveryDay 29d ago edited 29d ago

It really is mostly because it's mathematically convenient, absolute values don't become nice derivatives.

A lot of conventions are decided this way, actually.

There is also an argument that variance has useful geometric properties because it has a relationship to euclidian distance (but really this mostly just makes mathing with it easier) and some people prefer variance for punishing outliers disproportionately.

Example: the variance of a collection of random variables is equal to the sum of the variance of each component RV.

Variance is also the 2nd moment of a distribution, an important function used to describe distributions. The 0th moment is the total mass of the distribution, the 1st moment is it's mean, the 2nd is it's variance, the 3rd moment is related to skewedness and so on.

3

u/hrinda 28d ago

Mostly agree, but two corrections. Var(X + Y) = Var(X) + Var(Y) only holds when Cov(X, Y) = 0. In general there's an extra 2Cov(X, Y) term, so it's true for uncorrelated (e.g. independent) variables but not in general. Also, variance isn't the 2nd moment, it's the 2nd central moment, E[(X − μ)²]. The 2nd moment is E[X²], and Var(X) = E[X²] − (E[X])²

1

u/otsukarekun 26d ago

I agree with what you said except that absolute value not being a nice derivative. The derivative of absolutely value is -1 for x<0 and 1 for x>1, that's pretty nice. It breaks at 0 but that never stopped ReLU.

3

u/Due_Simple_9662 29d ago

Cause we head for the mean, not the median. 

2

u/Ok_Composer_1761 29d ago

Two words: orthogonal projection.

2

u/RaspberryTop636 28d ago

Absolute values give median as minimizer don't they, mean for squared resides. So because we like means more than medians is the dumb answer.

1

u/Savings-Cry-3201 28d ago

I square because I just don’t like negative numbers

2

u/rosentmoh 28d ago edited 28d ago

We use both, we just happen to call one "variance" and the other "mean absolute deviation".

Are you asking why most people are only taught about the former but not the latter? That's simply because the former is mathematically "easier" to understand; its various properties are easier to derive and use. But the latter very much has its place and use once you become a bit more "professional". That's all there is to it really; one's a more advanced concept than the other.

1

u/HolyInlandEmpire 26d ago

It's not just easier; moments can form minimally sufficient statistics for exponential distributions, which are by far the most important; the normal distribution from the central limit theorem, and many others as well. The absolute deviation cannot in general do that.

1

u/rosentmoh 26d ago edited 26d ago

I feel like that argument doesn't really hold; in both cases there's distributions for which either is or isn't part of a set of minimally sufficient statistics. This is more some old-school dogmatic infatuation with exponential distributions IMO, which surely has it's place, but depending on your application might also be completely irrelevant.

I'm more of a non-parametric guy anyways in the work I do, so for me both are very valid and useful statistics, but it certainly takes a bit more sophistication to prove useful results on absolute deviations than it does for squared ones. That's really all I'm saying here. I'm also really convinced that is the main reason for why one is often taught early on and the other not, instead of the deeper reason based on moments, which themselves are usually not taught that early.

I guess the point I'm trying to get across is that there's some very domain-specific "procedures" and algorithms that, on the face of it, don't even look like simple applications of statistics but indeed are rooted in and heavily reliant on properties of absolute deviations. So in other words, they're extremely useful and sometimes the only right tool for the job. Thus it stands to reason they should be taught more often and earlier; I'm just saying I think the reason that doesn't happen is because the math involved is simply a bit harder.

2

u/PotentialDeep5165 29d ago

Absolute value = square root of square of the number.

1

u/xeow 29d ago edited 29d ago

Not sure why you were downvoted. Maybe because what you said isn't quite 100% correct. It would be more technically accurate to say that the absolute value of a real number is the principal or non-negative square root of its square. (Remember that every positive real numbers has two square roots: one positive and one negative.)

Also, note that the absolute value (or modulus) of a complex number isn't necessarily equal to the square root of its square. For example, |i| is not equal to √(i^2), because |i| = 1 but √(i^2) = √(-1) = i.

1

u/PotentialDeep5165 29d ago

Guess I was too math specific rather than data science/stats oriented. These things happen.

2

u/Raccoon-Dentist-Two 28d ago

I can't explain the downvote but I think it's important to focus on why variances are defined the way they are, rather than a general observation about absolute values. It's been a long time since I was there but I have a vague memory of one reason: we want variance to behave like a Euclidean norm. Take a look at how variances behave when we add them.

1

u/PotentialDeep5165 27d ago

Agreed- going back to basics of definitions is always helpful. I shared the basics of abs value. Not as a solution but a starting point for the reflection of the basics. You are absolutely correct.

2

u/Raccoon-Dentist-Two 27d ago

Your post is good for people who think enough about it – the hard thing for most people is to move from the starting point to investigating a question like "so why is variance more than this?" Even experts often don't make that move because they've long since been accustomed to a good solution (or even a bad solution) that they take for granted. We all have limits in our critical thinking. I have a hunch that that's what drives a lot of downvotes all over the technical reddits.

1

u/xeow 29d ago

Yeah, Reddit is Reddit sometimes. I did give you an updoot!

1

u/BananaBird1 27d ago

But mean absolute value != root of mean squares.

1

u/jackedyfappadu 27d ago

no its not (x1^2 + x2^2)^0.5 != abs(X1) + abs(X2). Which was what op was refering to when he said absolute value instead of variances.

1

u/PotentialDeep5165 27d ago

That's root mean square of the sums. Derivation of least squares for fitting:
https://ocw.mit.edu/courses/18-02-multivariable-calculus-fall-2007/1f1dc7085b5af1c44b692f037b2810f9_least_sq_intrpol.pdf

I shared simple version of abs value, not of a collection.

Perhaps this derivation is what the OP needed for seeing why squares and not abs is used.

1

u/wristay 29d ago

One reason I could think of is that the variance is the Maximum Likelihood Estimator for the parameter sigma of a gaussian distribution. Gaussians pop up all over the place, so it makes sense that variance does too.

The laplace distribution, which has probability density function proportional to exp(-|x-mu|/b), has the mean absolute deviation for the MLE of the parameter b. b is the scale parameter.

The MLE is nice because in the limit of many samples (n-> infinity), it becomes "efficient", which means that the variance of that parameter estimate becomes the lowest it can possibly be. If you want to know more about that, look up Fisher information and the Cramér-Roa lower bound

1

u/Due_Simple_9662 29d ago

This is the answer!!

1

u/Tiny_Spread5712 29d ago

absolute values are more annoying to work with if you want to do more math.

If variance is the final term you are working with, it doesn't matter, but if you then have to plug variance into something else, then the absolute value starts to become a pain.

1

u/ForeignAdvantage5198 28d ago

because the normal pdf has a squared exponent. if you use absolute values you get least absolute deviations regression. etc.

1

u/HouseofVladingus 28d ago

Because variances add better.

For example, in a portfolio consisting of two assets weighted w1 and w2, of variance v1 and v1 and covariance c1,2, the variance of the combined portfolio is v1×w12 + v2xw22 + c1,2×w1×w2. Try doing that with absolute values.

1

u/mH48124 28d ago

数学的に都合が良いとは役に立つと言うこと。絶対値の方が分かりやすいなら自分だけで使えば良い。役に立たないから他人に見向きされないだけ。

1

u/Scary_Side4378 27d ago

squaring corresponds to L2 and absolute values correspond to L1.

L2 has the most convenient properties and there is really no reason to use anything else

1

u/pioneer6282 27d ago

It's because absolute values give you a crappy sharp V shape instead of a lovely smooth parabola like a square will give you. Makes it less simple to calculate values. Calculus loves smoothness. Smooth!

1

u/reflexive-polytope 26d ago

To take advantage of the wonderful theory of bilinear and quadratic forms on vector spaces.

Given a probability space Ω, the real-valued random-variables on Ω form a real vector space V. The covariance is a symmetric bilinear form on V, and the variance is the quadratic form on V determined by this bilinear form.

-1

u/rsk1111 29d ago

Statistics are designed to give statisticians "wiggle" room to make whatever claims they need to make. A straight line doesn't have any wiggle to fit anything.

These things show up all the time in statistics. Like modeling a binary distribution with a gaussian when the binomial is simpler. They get that extra parameter to play with for fitting.

0

u/[deleted] 29d ago

[deleted] — view deleted comment

1

u/Sneezycamel 29d ago

Deviation is the difference from the mean. OP is asking why we define variance in terms of square deviations instead of absolute deviations. There is nothing about standard deviations in the post.