Cumulative Mean and Variance

Computes cumulative the mean/variance of a vector X along an arbitrary dimension

You are now following this Submission

>> Y = cummean(X,DIM);
if X is MxN, Y is also MxN. To illustrate the functionality, lets assume X is a 1xN vector. Then, Y is a 1xN vector where the n-th entry in Y is given by mean(X(1:n)). So, Y(end) = mean(X), and Y(1) = X(1). cumvar works in the same way, and this can be done on an arbitrary dimensional X along dimension DIM. See screenshot for an example.

These functions are useful (at least to me) for determining how many iterations of a process are required until the mean and variance of the process are stable (ie: not changing with increasing iterations). Maybe useful to people doing Markhov chain stuff?

Cite As

Sumedh Joshi (2026). Cumulative Mean and Variance (https://www.mathworks.com/matlabcentral/fileexchange/26791-cumulative-mean-and-variance), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0