Skip to content

mean

statistics · scripts/statistics/mean.m

: m = mean (x)
: m = mean (x, dim)
: m = mean (x, vecdim)
: m = mean (x, "all")
: m = mean (…, nanflag)
: m = mean (…, outtype)
: m = mean (…, 'Weights', w)

Arithmetic mean of the elements of x.

By default the mean is taken along the first dimension whose size is not 1. dim picks one dimension, vecdim a set of dimensions that are reduced together, and "all" reduces every element to one number. nanflag is "includenan" (the default, a NaN in the data gives a NaN result) or "omitnan" (NaNs are left out of both the sum and the count). "omitmissing" is the same as "omitnan". A string scalar is accepted anywhere a flag char vector is. outtype is "default" (double, except that single input gives single), "double" or "native" (the class of x; integer results are rounded, half away from zero). 'Weights' supplies non-negative weights w, either a vector along the operating dimension or an array the size of x, and the result is the weighted mean.

Product note: dense real floating-point mean (x) with no further arguments is handled by the builtin __nexus_mean1__ when it is present; everything else runs through the m-file implementation below.