I'm working on averaging returns. For example, when you have a return of 100% in one year and a return of 0% in another year, your average return is 50%.
In another year, you do not have a return for some reason such as no data available for that year. The average of the two years with 100% in one year and no data in another year (programmers understand the concept of null better) is 100%.
Smart, luck or I'm data-fitting (an investing term) - you decide. Or, I have too much free time to make you waste your valuable time to read this post. LOL.
BTW, This formula to calculate return (b-a)/a is wrong. It should be (b-a)/abs(a) to take care of negative numbers.