Quote:
Is there a form of lazy evaluation where a function (like mean) returns an approximate value when operating on arrays
NO, it is a matter of common sense.
Mean calculation
the algorithm adds all values and divide total by number of values. And it gives exact answer, always, no matter what values are used.
In big O notation, for n values, it takes O(n)+ 1 division.
Quote:
when sorted are nearly linear (or we can find a linear Regression Model for data).
Sorting the dataset takes up to O(n²), so no.
Checking that is 'nearly linear' takes more than O(n), so no.
finding a regression model takes much more than O(n), so no.
Instead of sorting, just find minimum and maximum takes O(2n), so no. And you don't even know if data is 'nearly linear'.
There is plenty of ways to calc a mean, but since all of these algorithm takes more than simply adding all values, they are not used.
They takes much more work and result is wrong.