Computation of function moments


#1

I would like to compute \int_a^b(f-\bar{f})^ndx where \bar{f}=\int_a^bf dx. Is it possible to compute it in one pass?


#2

Wikipedia gives code for a Welford algorithm to do this here https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm , at least for the variance.


#3

Also see


#4

Thank you @aaowens and @Tamas_Papp.