<< str2array utility functions Statistical Visualization >>

NaN Toolbox >> NaN Toolbox > utility functions > sumskipnan

sumskipnan

adds all non-NaN values.

Calling Sequence

Y = sumskipnan(x [,DIM])
[Y,N,SSQ] = sumskipnan(x [,DIM])
[...] = sumskipnan(x, DIM, W)

Parameters

x :

input data

DIM :

dimension (default: []) empty DIM sets DIM to first non singleton dimension

W :

weight vector for weighted sum, numel(W) must fit size(x,DIM)

Y :

resulting sum

N :

number of valid (not missing) elements

SSQ :

sum of squares

Description

All NaN's are skipped; NaN's are considered as missing values. sumskipnan of NaN's only gives O; and the number of valid elements is return. sumskipnan is also the elementary function for calculating various statistics (e.g. MEAN, STD, VAR, RMS, MEANSQ, SKEWNESS, KURTOSIS, MOMENT, STATISTIC etc.) from data with missing values. sumskipnan implements the DIMENSION-argument for data with missing values. Also the second output argument return the number of valid elements (not NaNs)

the function flag_nans_occured() returns whether any value in x is a not-a-number (NaN)

features:

- can deal with NaN's (missing values)

- implements dimension argument.

- computes weighted sum

Examples

x = rand(1000000,1);
x(find(x>0.5))=%nan;
tic();[Y,N] = sumskipnan(x);t1=toc();
tic();[Y2] = nansum(x);t2=toc();
disp("sumskipnan is "+string(t2/t1)+" times faster");

See also

Authors


Report an issue
<< str2array utility functions Statistical Visualization >>