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?

Wikipedia gives code for a Welford algorithm to do this here Algorithms for calculating variance - Wikipedia , at least for the variance.

Also see

1 Like

Thank you @aaowens and @Tamas_Papp.