How to calculate the percentage when the old value is ZERO

I need logic for the following situation. I do not know how to do that.

Consider January . I have 10 $ income and February . I have 20 $ income .. p>

My growth will be ((20-10)/10)*100% = 100%

If I have 0 $ income for the March .

Then my growth will be ((0-10)/10)*100 % =-100 % . Should I call this a negative percentage? (I know his deflation)

Go to the next step

If now I have $ 20 income in April .

How can I calculate the growth now? I am sure that the following formula is incorrect, ((20-0)/0)*100 %= ?????

My main questions

  • Is there a better solution for finding a growth rate other than the above?

  • If I use the above formula, should I take some value as a reference? or is it also wrong?

+6
source share
5 answers

If you need to show growth in percent, then usually to display [NaN] or something like that in these cases. On the other hand, the growth rate will be reported in this case in the form of $ / month. Thus, in your example for April the growth rate will be calculated as ((20-0)/1 .

In any case, determining the correct method to report this special case is the user's decision. Is this in your custom requirements?

+6
source

This problem < . The problem is that it cannot be programmed on its own. When P is actually equal to zero, the concept of percentage change does not make sense. Zero cannot be expressed as a course to anything, since it is outside the definition boundary. The transition from "not to be" to "being" is not a change in being, but instead of creation .

+4
source

There is no growth rate from 0 to any other number. That is, there is no percentage increase from zero to more than zero, and there is no percentage decrease from zero to less than zero (negative number). What you need to decide is what you need to do when this happens. Here are two options that are convenient for me:

  • At any time when you need to show the rate of increase from scratch, output the infinity symbol (∞). This is Alt + 236 on your numeric keypad, if you're interested. You can also use negative infinity (-∞) for negative growth rate from zero.
  • Print an expression such as "[Increase / Decrease] from zero" or something in that direction.

Unfortunately, if you need a growth rate for further calculations, the above options will not work, but, on the other hand, any number would give your next calculations about incorrect data in any way, so the point is debatable. You will need to update your subsequent calculations to account for this.

As an aside, the ((New-Old) / Old) function will not work when your new and old values ​​are zero. You must create an initial check to make sure that both values ​​are zero and, if any, output a zero percent as the growth rate.

+2
source

How to deal with zeros when calculating percentage changes is a challenge for the researcher and requires some domain expertise. If the researcher believes that he will not distort the data, he can simply add a very small constant to all the values ​​to get rid of all zeros. For example, in financial series, when it comes to trading volume, we cannot do this, because trading volume = 0 means that: the asset was not traded at all. The value volume = 0 can be very different from volume = 0.00000000001. This is my preferred strategy in cases where I cannot logically add a small constant to all values. Consider the percentage change formula ((New-Old) / Old) * 100. If New = 0, then the percentage change will be -100%. This number really makes financial sense, as long as it is the minimum percentage change in the series (this is really guaranteed as the minimum percentage change in the series). What for? Because it shows that the volume of trade is experiencing the maximum possible decline, which goes from any number to 0, -100%. So, I will be fine with this value, which is in my series of percent changes. If I normalize this series, it’s even better, since this (possibly) relatively large number in absolute value will be analyzed on the same scale as other variables. Now, what if Old value = 0. This is a more complicated case. A change in percentage due to a transition from 0 to 1 will be equal to that due to a transition from 0 to a million: infinity. The fact that we call the percent change of "infinity" is problematic. In this case, I would set the infinities to np.nan and interpolate them.

The following graph shows what I discussed above. Starting with series 1, we get row 4, which is ready for analysis without INF or NaN.

enter image description here

One more thing: a lot of time, the reason for calculating the percentage change is to station the data. So, if your original series contains zero, and you want to convert it to a percentage change to achieve stationarity, first make sure it is not already installed. Because, if so, you do not need to calculate the percentage change. The fact is that the series that take the value of 0 a lot (OP problem) are likely to be stationary already, for example, the series of volumes discussed above. Imagine a cross section oscillating above and below zero, thus hitting 0 at times. Such a series is very likely already stationary.

+1
source

use the code below, as this is a 100% growth rate in case 0 for any number:

 IFERROR((NEW-OLD)/OLD,100%) 
0
source

Source: https://habr.com/ru/post/957829/


All Articles