# Does the mean of ROI, annualized = the mean of annualized ROI?

I'm not sure if I have a math error, or a comprehension error.

I have a series of ROIs over different periods (30 days, 5 years, etc)

roi = (value-cost)/cost


I also annualized all of these ROIs using this formula:

aroi = (value/cost)**(365/days) - 1


These return identical values for a period of 365 days as expected.

Now, here is where I get confused. I will use a period of 2 years as example.

If I take my mean of ROIs over this two year period, I get 23.6% which annualizes to 11.17%.

But if I take these same ROI's, annualize all of them, and take the mean of that, I get 10.32%.

Do I have a math error? Do we expect these numbers to be the same? And if not, which is the better estimate?

## migrated from stackoverflow.comJul 24 '18 at 1:32

This question came from our site for professional and enthusiast programmers.

## 1 Answer

There is a difference between a large group of mice and a group of large mice - while they'd both make an excellent horror movie, the plot lines would probably be considerably different. So, yes, order definitely has an impact.

In general, the answer is (and I know mathematicians will hate this) "it depends" :-). You cannot rely on the same results if you change the order of operations.

I'm tempted to say it's because of commutativity but, from memory, that applies to a single operation with the quantities swapped. So, multiplication is commutative and division is not:

10 x 5 = 50,    5 x 10 =  50,    commutative.
10 / 5 =  2,    5 / 10 = 0.5,    non-commutative.


Whether that term can apply to the order of mutiple operations, I couldn't say for sure(a), but it seems related.

In fact, there are a great many operations which produce different results depending on the order. For example, the sum of the square roots of 49 and 64 is 7 + 8 or 15, whereas the square root of the sum of 49 and 64 (113) is about 10.6.

There are also operations that produce the same results, such as "half of the sum" and "sum of the halves".

But your particular set of operations appears to fall in the "different results" category.

(a) And, since this site is full of math geeks just waiting to pummel me if I make a fundamental mistake like that, I'm not going to risk it :-)

• +1 for the first sentence (at least) ! – Claude Leibovici Jul 24 '18 at 5:36