 TallyInto - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Statistics

 TallyInto
 compute data frequencies Calling Sequence TallyInto(X, R, options) Parameters

 X - R - range or list(range) or Vector; grouping pattern options - (optional) equation(s) of the form option=value where option is one of weights, ignore, bins or output; specify options for the TallyInto function. Options

 The options argument can contain the following option:
 • weights=Array, or list -- Vector of weights. If weights are specified, the TallyInto function will compute cumulative weights of data items in each interval. Note that the weights provided must have type/realcons and the returned frequencies are floating-point, even if the problem is specified with exact values. Both the data array and the weights array must have the same number of elements.
 • ignore=truefalse -- This option is used to specify how to handle non-numeric data. If ignore is set to true all non-numeric items in X will be ignored.
 • bins=posint -- If this option is set, every data range in R will be subdivided into the given number of equal subintervals. The default value of bins is 10 if only one range is given and 1 if multiple ranges are given. If R is specified as a Vector, then the bins option is ignored.
 • output=list, or table -- By default (output=list) a list of equation of the form range=frequency is returned. If the value of this option is set to output=table this list is converted to an object of type table. Description

 • The TallyInto function groups together elements from X which belong to the same data range and computes their frequencies. (See also Statistics[Tally]).
 • The first parameter X is the data set.
 • The second argument R is used to specify how the data should be grouped. The value of R can be a range or a list of ranges, or it can be a Vector (or other one-dimensional rtable) of numbers.
 If ranges are specified, then for each range, TallyInto will compute the number of data items in the corresponding interval. The intervals are not assumed to be disjoint, so any data item may belong to more than one interval (or none of them). Each interval can be divided into a number of equal-sized subintervals using the bins option (see below). Alternatively, you can pass default as the value for R, which tells TallyInto to use the interval between the smallest and the largest data items.
 If R is a Vector of numbers x0 < x1 < ... < xn, then instead Maple uses the $n$ intervals [x0, x1), [x1, x2), ..., [x(n-1), xn]. The bins option is ignored in this case.
 If a given range is subdivided into $n$ subranges, then each subrange except for the rightmost one corresponds to an interval that is closed on the left and open on the right; the rightmost interval is closed on both sides. That is, a value that is equal to a boundary value will be part of the subrange on its right (except if it is at the right of the whole range). Similarly, if R is a Vector, boundary points will be put into the subinterval on the right (except the rightmost point will be put into the last subinterval). Note, however, that both the boundary points and the data points will be converted to floating-point, and this could conceivably cause the floating-point versions of data points to lie on the other side of boundary points than the exact versions do. Notes

 • The underlying computation is done in floating-point; therefore, all data provided must have type/realcons and all returned frequencies are floating-point, even if the problem is specified with exact values.  For more information about numeric computation in the Statistics package, see the Statistics[Computation] help page.
 • Note that TallyInto will return an error if it is required to split an infinite interval (i.e. if the value of bins is different from 1 and at least one boundary of an interval is infinite). Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Array}\left(\left[\mathrm{seq}\left(\frac{1}{i},i=1..100\right)\right]\right)$
 ${A}{≔}\left[\begin{array}{cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc}{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}}& \frac{{1}}{{11}}& \frac{{1}}{{12}}& \frac{{1}}{{13}}& \frac{{1}}{{14}}& \frac{{1}}{{15}}& \frac{{1}}{{16}}& \frac{{1}}{{17}}& \frac{{1}}{{18}}& \frac{{1}}{{19}}& \frac{{1}}{{20}}& \frac{{1}}{{21}}& \frac{{1}}{{22}}& \frac{{1}}{{23}}& \frac{{1}}{{24}}& \frac{{1}}{{25}}& \frac{{1}}{{26}}& \frac{{1}}{{27}}& \frac{{1}}{{28}}& \frac{{1}}{{29}}& \frac{{1}}{{30}}& \frac{{1}}{{31}}& \frac{{1}}{{32}}& \frac{{1}}{{33}}& \frac{{1}}{{34}}& \frac{{1}}{{35}}& \frac{{1}}{{36}}& \frac{{1}}{{37}}& \frac{{1}}{{38}}& \frac{{1}}{{39}}& \frac{{1}}{{40}}& \frac{{1}}{{41}}& \frac{{1}}{{42}}& \frac{{1}}{{43}}& \frac{{1}}{{44}}& \frac{{1}}{{45}}& \frac{{1}}{{46}}& \frac{{1}}{{47}}& \frac{{1}}{{48}}& \frac{{1}}{{49}}& \frac{{1}}{{50}}& \frac{{1}}{{51}}& \frac{{1}}{{52}}& \frac{{1}}{{53}}& \frac{{1}}{{54}}& \frac{{1}}{{55}}& \frac{{1}}{{56}}& \frac{{1}}{{57}}& \frac{{1}}{{58}}& \frac{{1}}{{59}}& \frac{{1}}{{60}}& \frac{{1}}{{61}}& \frac{{1}}{{62}}& \frac{{1}}{{63}}& \frac{{1}}{{64}}& \frac{{1}}{{65}}& \frac{{1}}{{66}}& \frac{{1}}{{67}}& \frac{{1}}{{68}}& \frac{{1}}{{69}}& \frac{{1}}{{70}}& \frac{{1}}{{71}}& \frac{{1}}{{72}}& \frac{{1}}{{73}}& \frac{{1}}{{74}}& \frac{{1}}{{75}}& \frac{{1}}{{76}}& \frac{{1}}{{77}}& \frac{{1}}{{78}}& \frac{{1}}{{79}}& \frac{{1}}{{80}}& \frac{{1}}{{81}}& \frac{{1}}{{82}}& \frac{{1}}{{83}}& \frac{{1}}{{84}}& \frac{{1}}{{85}}& \frac{{1}}{{86}}& \frac{{1}}{{87}}& \frac{{1}}{{88}}& \frac{{1}}{{89}}& \frac{{1}}{{90}}& \frac{{1}}{{91}}& \frac{{1}}{{92}}& \frac{{1}}{{93}}& \frac{{1}}{{94}}& \frac{{1}}{{95}}& \frac{{1}}{{96}}& \frac{{1}}{{97}}& \frac{{1}}{{98}}& \frac{{1}}{{99}}& \frac{{1}}{{100}}\end{array}\right]$ (1)
 > $\mathrm{TallyInto}\left(A,\mathrm{default},\mathrm{bins}=5\right)$
 $\left[{0.0100000000000000}{..}{0.208000000000000}{=}{96}{,}{0.208000000000000}{..}{0.406000000000000}{=}{2}{,}{0.406000000000000}{..}{0.604000000000000}{=}{1}{,}{0.604000000000000}{..}{0.802000000000000}{=}{0}{,}{0.802000000000000}{..}{1.}{=}{1}\right]$ (2)
 > $\mathrm{TallyInto}\left(A,\mathrm{default},\mathrm{bins}=3\right)$
 $\left[{0.0100000000000000}{..}{0.340000000000000}{=}{98}{,}{0.340000000000000}{..}{0.670000000000000}{=}{1}{,}{0.670000000000000}{..}{1.}{=}{1}\right]$ (3)
 > $W≔\mathrm{Array}\left(\left[\mathrm{seq}\left(i,i=1..100\right)\right]\right)$
 ${W}{≔}\left[\begin{array}{cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc}{1}& {2}& {3}& {4}& {5}& {6}& {7}& {8}& {9}& {10}& {11}& {12}& {13}& {14}& {15}& {16}& {17}& {18}& {19}& {20}& {21}& {22}& {23}& {24}& {25}& {26}& {27}& {28}& {29}& {30}& {31}& {32}& {33}& {34}& {35}& {36}& {37}& {38}& {39}& {40}& {41}& {42}& {43}& {44}& {45}& {46}& {47}& {48}& {49}& {50}& {51}& {52}& {53}& {54}& {55}& {56}& {57}& {58}& {59}& {60}& {61}& {62}& {63}& {64}& {65}& {66}& {67}& {68}& {69}& {70}& {71}& {72}& {73}& {74}& {75}& {76}& {77}& {78}& {79}& {80}& {81}& {82}& {83}& {84}& {85}& {86}& {87}& {88}& {89}& {90}& {91}& {92}& {93}& {94}& {95}& {96}& {97}& {98}& {99}& {100}\end{array}\right]$ (4)
 > $\mathrm{TallyInto}\left(A,\mathrm{default},\mathrm{bins}=3,\mathrm{weights}=W\right)$
 $\left[{0.0100000000000000}{..}{0.340000000000000}{=}{5047.}{,}{0.340000000000000}{..}{0.670000000000000}{=}{2.}{,}{0.670000000000000}{..}{1.}{=}{1.}\right]$ (5)
 > $\mathrm{FrequencyTable}\left(A,\mathrm{bins}=3,\mathrm{weights}=W\right)$
 $\left[\begin{array}{ccccc}{0.0100000000000000}{..}{0.340000000000000}& {5047.}& {99.9405940594059}& {5047.}& {99.9405940594059}\\ {0.340000000000000}{..}{0.670000000000000}& {2.}& {0.0396039603960396}& {5049.}& {99.9801980198020}\\ {0.670000000000000}{..}{1.}& {1.}& {0.0198019801980198}& {5050.}& {100.}\end{array}\right]$ (6)
 > $\mathrm{TallyInto}\left(A,\left[-1..0.5,-0.5..0.5,-1..1\right],\mathrm{bins}=3\right)$
 $\left[{-1.}{..}{-0.500000000000000}{=}{0}{,}{-0.500000000000000}{..}{0.}{=}{0}{,}{0.}{..}{0.500000000000000}{=}{99}{,}{-0.500000000000000}{..}{-0.166666666666667}{=}{0}{,}{-0.166666666666667}{..}{0.166666666666667}{=}{94}{,}{0.166666666666667}{..}{0.500000000000000}{=}{5}{,}{-1.}{..}{-0.333333333333333}{=}{0}{,}{-0.333333333333333}{..}{0.333333333333333}{=}{97}{,}{0.333333333333333}{..}{1.}{=}{3}\right]$ (7)
 > $\mathrm{TallyInto}\left(A,\left[-1..0.5,-0.5..0.5,-1..1\right],\mathrm{bins}=3,\mathrm{weights}=W\right)$
 $\left[{-1.}{..}{-0.500000000000000}{=}{0.}{,}{-0.500000000000000}{..}{0.}{=}{0.}{,}{0.}{..}{0.500000000000000}{=}{5049.}{,}{-0.500000000000000}{..}{-0.166666666666667}{=}{0.}{,}{-0.166666666666667}{..}{0.166666666666667}{=}{5029.}{,}{0.166666666666667}{..}{0.500000000000000}{=}{20.}{,}{-1.}{..}{-0.333333333333333}{=}{0.}{,}{-0.333333333333333}{..}{0.333333333333333}{=}{5044.}{,}{0.333333333333333}{..}{1.}{=}{6.}\right]$ (8)

An example with explicitly specified bounds.

 > $A≔\mathrm{Sample}\left(\mathrm{Exponential}\left(1\right),{10}^{5}\right):$
 > $\mathrm{PowersOf2}≔\mathrm{Vector}\left(\left[\mathrm{seq}\left({2}^{i},i=-4..4\right)\right]\right)$
 ${\mathrm{PowersOf2}}{≔}\left[\begin{array}{c}\frac{{1}}{{16}}\\ \frac{{1}}{{8}}\\ \frac{{1}}{{4}}\\ \frac{{1}}{{2}}\\ {1}\\ {2}\\ {4}\\ {8}\\ {16}\end{array}\right]$ (9)
 > $\mathrm{TallyInto}\left(A,\mathrm{PowersOf2}\right)$
 $\left[{0.0625000000000000}{..}{0.125000000000000}{=}{5661}{,}{0.125000000000000}{..}{0.250000000000000}{=}{10415}{,}{0.250000000000000}{..}{0.500000000000000}{=}{17142}{,}{0.500000000000000}{..}{1.}{=}{23932}{,}{1.}{..}{2.}{=}{23206}{,}{2.}{..}{4.}{=}{11604}{,}{4.}{..}{8.}{=}{1850}{,}{8.}{..}{16.}{=}{36}\right]$ (10)

Compare this histogram:

 > $\mathrm{Histogram}\left(A,'\mathrm{binbounds}'=\mathrm{PowersOf2}\right)$  Compatibility

 • The R parameter was updated in Maple 16.

 See Also