transform(deprecated)/split - Maple Help

stats[transform, split]

split one data list into several

 Calling Sequence stats[transform, split[n]](data) transform[split[n]](data)

Parameters

 n - positive integer data - statistical list

Description

 • Important: The stats package has been deprecated. Use the superseding package Statistics instead.
 • The function split of the subpackage stats[transform, ...] splits the data list, data, into n data lists of same weight.
 • Missing items are taken into account.
 • This function is useful in constructing histograms where each bar has the same area.

Examples

Important: The stats package has been deprecated. Use the superseding package Statistics instead.

 > $\mathrm{with}\left(\mathrm{stats}\right):$
 > $\mathrm{data}≔\left[1,2,3,4,5\right]$
 ${\mathrm{data}}{≔}\left[{1}{,}{2}{,}{3}{,}{4}{,}{5}\right]$ (1)
 > ${\mathrm{transform}}_{{\mathrm{split}}_{3}}\left(\mathrm{data}\right)$
 $\left[\left[{1}{,}{\mathrm{Weight}}{}\left({2}{,}\frac{{2}}{{3}}\right)\right]{,}\left[{\mathrm{Weight}}{}\left({2}{,}\frac{{1}}{{3}}\right){,}{3}{,}{\mathrm{Weight}}{}\left({4}{,}\frac{{1}}{{3}}\right)\right]{,}\left[{\mathrm{Weight}}{}\left({4}{,}\frac{{2}}{{3}}\right){,}{5}\right]\right]$ (2)

The following is an extended example where a list of numbers will be randomly generated, used in a histogram which will be compared to the theoretical distribution. Generate 300 numbers (reduce this number for faster results), randomly generated with a normal distribution

 > $\mathrm{Numbers}≔\left[{\mathrm{random}}_{\mathrm{normald}}\left(300\right)\right]:$

Sort the data.

 > $\mathrm{Numbers_sorted}≔{\mathrm{transform}}_{\mathrm{statsort}}\left(\mathrm{Numbers}\right):$

Number of lists is set to 5 (increase it for a better resolution, but ensure there are enough points in the list).

 > $\mathrm{N_list}≔5:$

Split into lists of equal weight.

 > $\mathrm{Split_lists}≔{\mathrm{transform}}_{{\mathrm{split}}_{\mathrm{N_list}}}\left(\mathrm{Numbers_sorted}\right):$

Obtain classes of equal weight from those lists. Make the total weight equal to 1.

 > $\mathrm{Classes}≔\mathrm{map}\left(x→\mathrm{Weight}\left({\mathrm{describe}}_{\mathrm{range}}\left(x\right),\frac{1}{\mathrm{N_list}}\right),\mathrm{Split_lists}\right):$

Construct histogram:

 > $\mathrm{Hist}≔{\mathrm{statplots}}_{\mathrm{histogram}}\left(\mathrm{Classes}\right):$

Create a theoretical curve

 > $\mathrm{Theor}≔\mathrm{plot}\left({\mathrm{statevalf}}_{\mathrm{pdf},\mathrm{normald}},{\mathrm{describe}}_{\mathrm{range}}\left(\mathrm{Numbers}\right)\right):$

Display both the theoretical curve and the histogram.

 > ${\mathrm{plots}}_{\mathrm{display}}\left(\mathrm{Hist},\mathrm{Theor}\right)$