6
$\begingroup$

Here is a simple Python implementation of the arithmetic, geometric, and harmonic means of a (non-empty) list of numbers:

import functools
import math
import operator

def arithmetic_mean(arr):
    return sum(arr) / len(arr)

def geometric_mean(arr):
    return functools.reduce(operator.mul, arr, 1) ** (1 / len(arr))

def harmonic_mean(arr):
    return len(arr) / sum(1 / x for x in arr)

Note that the harmonic mean is undefined if any value is zero, and the geometric mean may be complex if some values are negative. So for the sake of simplicity, assume that all numbers are positive.

If you put the three means into a list, calculate the same three means on that list, and do it repeatedly, it seems that the means will always converge to one number. For example, starting with a list of integers from 1 to 10, you get $4.396721093094297$.

>>> arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> while True:
...     a = arithmetic_mean(arr)
...     g = geometric_mean(arr)
...     h = harmonic_mean(arr)
...     print(f'a = {a}, g = {g}, h = {h}')
...     arr = [a, g, h]
...     if len(set(arr)) == 1:
...         break
...
a = 5.5, g = 4.528728688116765, h = 3.414171521474055
a = 4.480966736530273, g = 4.39752289694313, h = 4.313272842437052
a = 4.397254158636819, g = 4.396721125488126, h = 4.396188059783766
a = 4.396721114636237, g = 4.396721093094297, h = 4.396721071552359
a = 4.396721093094297, g = 4.396721093094297, h = 4.396721093094297

I will call this value the iterated triple mean of arr.

I'm wondering: Is there a formula to obtain the iterated triple mean “directly”, without using an iterative or recursive definition?

$\endgroup$
2
  • 1
    $\begingroup$ This seems relevant. $\endgroup$ Commented Apr 4, 2024 at 4:06
  • 1
    $\begingroup$ After the first averaging, this is the dynamical system for $X=(a,g,h)$ denoting arithmetic, geometric, and harmonic means, and evolution given by $X_{n+1}=((a_n+g_n+h_n)/3, \ (a_ng_nh_n)^{1/3}, \ 3(a_n^{-1}+g_n^{-1}+h_n^{-1})^{-1})$. It is straightforward to verify that if the system has a fixed point $X_{n+1}=X_n$ for positive $a,g,h$ then that must be along the ray $a=g=h$. Beyond this seems very nontrivial $\endgroup$ Commented Apr 4, 2024 at 7:36

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.