# How does the different use of | cause a difference between these equations?

I have the equations $$sMAPE = n^{-1}\sum_{i=1}^n\left|\frac{y_i - f_i}{(y_i+f_i)/2}\right|$$ and $$sMAPE = n^{-1}\sum_{i=1}^n \frac{|y_i-f_i|}{(|y_i|+|f_i|)/2}$$ but I don't understand what $|$ means.

-
Absolute values. – Andrés E. Caicedo Feb 1 '13 at 2:57

As Andres Caicedo points out in the comments, this symbol is absolute value.

What it does is tell you how far away from $0$ a number is. For instance $\lvert -5 \rvert$ would be $5$ because it is $5$ steps away from $0$.

This causes a difference between the two equations because we are taking this at different times For example

$$\lvert 5 - (-5) \rvert = 10$$ But $$\lvert 5 \rvert - \lvert -5 \rvert = 5 - 5 = 0$$

-

I'm not sure anyone actually answered the question in your title post. Andres's comment and Deven's answer tell you what the vertical bar means, and Deven hints at why the two expressions aren't equal. But if you want it spelled out:

It turns out that the absolute value of a quotient is the quotient of the absolute values, i.e. $$\left|\frac{a}{b}\right|=\frac{|a|}{|b|}$$ It follows that $$\left|\frac{y_i-f_i}{(y_i+f_i)/2}\right|=\frac{|y_i-f_i|}{|(y_i+f_i)/2|}=\frac{|y_i-f_i|}{|y_i+f_i|/2}$$ On the other hand, in general, we have $$|a+b|\neq|a|+|b|$$ although this statement does become true if $a$ and $b$ have the same sign. So you can't conclude that $$|y_i+f_i|=|y_i|+|f_i|$$ unless you know that $y_i$ and $f_i$ have the same sign.

-