# How to compute the relative difference between two numbers?

I currently do quality assurance work for a company that collects social media data and the term 1% gets tossed around a lot. They would like for to ensure that the data in our database has less than a 1% difference between the our database and source we are getting it from, but this is all relative to the value type.

For example, if we are talking about Facebook "likes" then a difference of 2 and 4 isn't a big deal, but 20,000 and 40,000 is, however, with a typical percent difference formula both of these sets result in a percent difference of 100%.

Is there some sort of formula that can is less sensitive for those extremely small values but is still sensitive enough to consider the difference between 10 and 20 to be greater than 1%?

• You might consider $e^x \ge cy$ where $x$ is the comparison percentage and $y$ is the base group size so that the percentage difference and the group size both have a voice Sep 21 '13 at 22:45
• Can you try to be a little more specific about the purpose of the statistic? Sep 22 '13 at 1:07

There are many functions to measure this and it depends on your choice. For instance, $$100\left(\dfrac{\vert x-x_{ref} \vert}{\vert x_{ref} \vert} \right) \left(1-\exp \left(-\dfrac{\vert x-x_{ref} \vert}{a} \right) \right) \%$$ If you choose a reasonably large value of $a$, then smaller values of the difference wont cause a huge change but larger values of difference will show a number closer to the normal percentage you want. For instance, if we choose $a=100$, we then have the following.
If $x_{ref} = 2$ and $x=4$, gives us a percentage of \begin{align} 100 \times \dfrac{4-2}{2} \times \left(1-\exp \left(- \dfrac{\vert4-2\vert}{100}\right)\right) & = 100 \times \dfrac22 \times (1-\exp(-0.02))\\ & \approx 100 \times 0.0198\\ & = 1.98 \% \end{align}
If $x_{ref} = 20000$ and $x=40000$, gives us a percentage of \begin{align} 100 \times \dfrac{40000-20000}{20000} \times \left(1-\exp \left(- \dfrac{\vert40000-20000\vert}{100}\right)\right) & = 100 \times \dfrac{20000}{20000} \times \left(1-\exp \left(- 200\right)\right)\\ & \approx 100 \% \end{align}
The choice of $a$ depends on from what value of $x_{ref}$, you want the change to actually measure close to the true percentage.
• @EinDoofus $\exp$ is nothing but $e$, the mathematical constant, i.e., $\exp(x) = e^x$. As I have shown above, for $a=100$, $2-4$ will give a percentage increase of $\approx 1.98 \%$, $2000-4000$ will give a percentage increase of $\approx 99.99 \%$. You can play around with this by choosing a different value for $a$.