Statistics - Maple Help

Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Data Manipulation : Statistics/Count

Statistics

 Count
 compute number/total weight of observations
 CountMissing
 compute number/total weight of missing observations

 Calling Sequence Count(X, options) CountMissing(X, options)

Parameters

 X - options - (optional) equation(s) of the form option=value where option is one of ignore, or weights; specify options for the Count and CountMissing functions

Description

 • The Count function computes the size of the data sample X. If weights are provided, the Count function computes the cumulative weight of all observations in X. Missing values can be ignored (see option ignore).
 • The CountMissing function counts missing values in the data sample X. If weights are provided, the CountMissing function computes the cumulative weight of all missing elements in X.
 • The first parameter X is a data sample - given as e.g. a Vector. Alternatively, both Count and CountMissing understand DataFrame objects or Matrix data sets: if X is a Matrix, a 2-dimensional Array, or a list of lists, then the returned result is a row Vector containing the results of each column; if X is a DataFrame, the result is a DataSeries containing the results of each column. If the weights option is supplied with a Matrix data set, then the weights are interpreted as applying per row of the data.
 • All data provided must have type/realcons. If the weights option is provided or if X is a Matrix data set, then the result(s) are provided as floating-point, even if the problem is specified with exact values.

Options

 The options argument can contain one or more of the options shown be low.
 • ignore=truefalse -- This option controls how missing data is handled by the Count command. By default (ignore = false) all missing values are accounted for in the final result. If ignore is set to false all missing values will be ignored.
 • weights=Vector -- Data weights. The number of elements in the weights Vector must be equal to the number of elements in the original data sample. By default all elements in X are assigned weight $1$.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔⟨1,2,3,4,5,6,7,8,\mathrm{undefined},\mathrm{undefined}⟩:$
 > $W≔⟨1,\frac{1}{2},\frac{1}{3},\frac{1}{4},\frac{1}{5},\frac{1}{6},\frac{1}{7},\frac{1}{8},\frac{1}{9},\frac{1}{10}⟩:$
 > $\mathrm{Count}\left(A\right)$
 ${10}$ (1)
 > $\mathrm{CountMissing}\left(A\right)$
 ${2}$ (2)
 > $\mathrm{Count}\left(A,\mathrm{weights}=W\right)$
 ${2.92896825396825}$ (3)
 > $\mathrm{CountMissing}\left(A,\mathrm{weights}=W\right)$
 ${0.211111111111111}$ (4)
 > $\mathrm{Count}\left(A,\mathrm{ignore}\right)$
 ${8}$ (5)
 > $\mathrm{Count}\left(A,\mathrm{weights}=W,\mathrm{ignore}\right)$
 ${2.71785714285714}$ (6)
 > $\mathrm{Count}\left(\left[1,2,3,4,5,\mathrm{undefined}\right]\right)$
 ${6}$ (7)
 > $\mathrm{CountMissing}\left(\left[1,2,3,4,5,\mathrm{undefined}\right]\right)$
 ${1}$ (8)

Consider the following Matrix data set.

 > $M≔\mathrm{Matrix}\left(\left[\left[3,1130,114694\right],\left[4,1527,\mathrm{undefined}\right],\left[3,907,88464\right],\left[2,878,96484\right],\left[4,\mathrm{undefined},128007\right]\right]\right)$
 ${M}{:=}\left[\begin{array}{ccc}{3}& {1130}& {114694}\\ {4}& {1527}& {\mathrm{undefined}}\\ {3}& {907}& {88464}\\ {2}& {878}& {96484}\\ {4}& {\mathrm{undefined}}& {128007}\end{array}\right]$ (9)

We compute the number of non-missing entries of each column, and the weighted number of missing entries.

 > $\mathrm{Count}\left(M,'\mathrm{ignore}'\right)$
 $\left[\begin{array}{ccc}{5}& {4}& {4}\end{array}\right]$ (10)
 > $\mathrm{CountMissing}\left(M,'\mathrm{weights}'=\left[\mathrm{seq}\left(1..5\right)\right]\right)$
 $\left[\begin{array}{ccc}{0.}& {5.}& {2.}\end{array}\right]$ (11)

Compatibility

 • The X parameter was updated in Maple 16.