\section{Missing values}

Most operators can handle missing values.
The default missing value for GRIB, SERVICE, EXTRA and IEG files is $-9.e^{33}$. 
The {\CDO} option '-m $<$missval$>$' overwrites the default missing value.
In netCDF files the variable attribute '\_FillValue' is used as a missing value.
The operator '\htmlref{setmissval}{setmissval}' can be used to set a new missing value.

The {\CDO} use of the missing value is shown in the following tables,
where one table is printed for each operation.
The operations are applied to arbitrary numbers $a$, $b$, the special case $0$,
and the missing value $miss$.
%Gray fields are of particular interest.
For example the table named "addition" shows that the sum of an
arbitrary number $a$ and the missing value is the missing value,
and the table named "multiplication" shows that $0$ multiplied by missing
value results in $0$.


\hspace{2cm}
\vspace{2mm}
\begin{minipage}[t]{8cm}

%\ifpdf
%\begin{longtable}[t]{|c||c|c|c|}
%\else
\begin{tabular}[t]{|>{\columncolor{pcolor1}}c|c|c|c|}
%\fi
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf addition}&  \makebox[2cm]{b} & & \makebox[2cm]{miss} \\
\hline
  {a}         &       $a + b$   & &   $miss$ \\
\hline
  {miss}      &       $miss$    & &   $miss$ \\
\hline
%\end{tabular}
%
%\vspace{1mm}
%
%\begin{tabular}[t]{|c||c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf subtraction}&  \makebox[2cm]{b} & & \makebox[2cm]{miss} \\
\hline
  {a}         &       $a - b$   &  &  $miss$ \\
\hline
  {miss}      &       $miss$    &  &  $miss$ \\
\hline
%\end{tabular}
%
%\vspace{1mm}
%
%\begin{tabular}[b]{|c||c|c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf multiplication} & \makebox[2cm]{b} & \makebox[2cm]{0} & \makebox[2cm]{miss} \\
\hline
  {a}         &       $a * b$   &     $0$   &    $miss$ \\
\hline
  {0}         &        $0$      &     $0$   &     $0$   \\
\hline
  {miss}      &       $miss$    &     $0$   &    $miss$ \\
\hline
%\end{tabular}
%
%\vspace{1mm}
%
%\begin{tabular}[b]{|c||c|c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf division} & \makebox[2cm]{b} & \makebox[2cm]{0} & \makebox[2cm]{miss} \\
\hline
  {a}         &       $a / b$   &    $miss$ &    $miss$ \\
\hline
  {0}        &        $0$      &    $miss$ &    $miss$ \\
\hline
  {miss}      &       $mis$s    &    $miss$ &    $miss$ \\
\hline
%\end{tabular}
%
%\vspace{1mm}
%
%\begin{tabular}[b]{|c||c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf maximum} & \makebox[2cm]{b} & & \makebox[2cm]{miss} \\
\hline
  {a}         &      $max(a,b)$ & &    $a$   \\
\hline
  {miss}      &        $b$      & &   $miss$ \\
\hline
%\end{tabular}
%
%\vspace{1mm}
%
%\begin{tabular}[b]{|c||c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf minimum} & \makebox[2cm]{b} & & \makebox[2cm]{miss} \\
\hline
  {a}         &      $min(a,b)$ &  &   $a$   \\
\hline
  {miss}      &        $b$      &  &  $miss$ \\
\hline
%\end{tabular}
%%\end{minipage}
%
%\hspace{2cm}
%%\begin{minipage}[t]{8cm}
%\vspace{1mm}
%
%\begin{tabular}[b]{|c||c|c|}
\hline
\rowcolor{pcolor1}
\cellcolor{pcolor2}
\makebox[2.3cm]{\bf sum} & \makebox[2cm]{b} & & \makebox[2cm]{miss} \\
\hline
  {a}         &         $a + b$ & &     $a$   \\
\hline
  {miss}      &        $b$      & &   $miss$ \\
\hline
%\ifpdf
%\end{longtable}
%\else
\end{tabular}
%\fi

\end{minipage}

\vspace{2mm}

The handling of missing values by the operations "minimum" and "maximum" may
be surprising, but the definition given here is more consistent with that
expected in practice. Mathematical functions (e.g. $log$, $sqrt$, etc.)
return the missing value if an argument is the missing value or
an argument is out of range.

All statistical functions ignore missing values, treading them as not belonging
to the sample, with the side-effect of a reduced sample size.

\subsection{Mean and average}

An artificial distinction is made between the notions mean and average.
The mean is regarded as a statistical function, whereas the average is found simply
by adding the sample members and dividing the result by the sample size.
For example, the mean of 1, 2, $miss$ and 3 is $(1+2+3)/3=2$,
whereas the average is $(1+2+miss+3)/4=miss/4=miss$.
If there are no missing values in the sample, the average and mean are identical.
