Name for incrementally calculating a mean

If μ = 4 and n = 2 and suddenly I have a new datum of 22 I can add 1 to n and recalculate μ as (4*2+22)/3 = 10 without even looking back at the old data. This can be used as an optimization to reduce recalculations as data grows.

But does it have a name? Ideally a name that would drive someone to a definition of the function I just used. What's a good way to describe this?

Looking for something to say to coders who didn’t exactly master statistics.

• In ML contexts algorithms that calculate the quantity by the sequentially operating on one single datum or one subset of data at a time are called online learning algorithms or batch learning algorithms, respectively, but those seem too specific for this case to my ears. There might be a better name; into the same category could be put very different things like the greedy matroid optimization problem (optimal member of matroid can be picked by looking at them one at a time, keeping or switching selection). I don't know whether all O(N) (in time and memory) computations fall into this class. Commented Aug 20, 2022 at 13:20
• @jwimberley the function I’m describing is strictly O(1). It’s only about calculating a new mean from an old one and it’s n along with a new datapoint. That’s all. Nothing more. Commented Aug 20, 2022 at 18:17
• Conventionally in statistics, Greek letters are used for population quantities ($\mu$ typically being a population mean) Where you write $\mu$, do you intend it to be the observed value of a sample mean? It might help to define terms and state so explicitly ... I don't know that the mean updating formula alone has a name but when combined with a common variance updating formula, we get Welford's algorithm: en.wikipedia.org/wiki/… Commented Aug 21, 2022 at 3:28