FrequencyPlot - Maple Help

Statistics

 FrequencyPlot
 generate frequency plots

 Calling Sequence FrequencyPlot(X, options, plotoptions) FrequencyPlot['interactive'](X)

Parameters

 X - data options - (optional) equation(s) of the form option=value where option is one of averageshifted, binbounds, bincount, binwidth, color, discrete, frequencyscale, ignore, maxbins, minbins, or range; specify options for generating the frequency plot plotoptions - options to be passed to the plots[display] command

Description

 • The FrequencyPlot command generates a frequency plot for the specified data. A frequency plot is similar to a histogram except that a frequency plot has lines connecting frequency values and a histogram has bars at the frequency values. Unlike the Histogram command, the FrequencyPlot command supports multiple data samples. Ordinary and average shifted frequency plots are supported. An average shifted frequency plot is obtained by calculating $m$ frequency plots with the same binwidth $w$, shifting them by $\frac{w}{m}$ and taking the average. Average shifted frequency plots are smoother than ordinary frequency plots and are less dependent on the choice of the origin.
 • The first parameter X is either a single data sample - given as e.g. a Vector - or a list of data samples. Note that the individual samples may be of variable size.
 • If the ['interactive'] option is used, then a dialog box appears that allows for customized creation of the plot.

Options

 The options argument can contain one or more of the options shown below. All unrecognized options will be passed to the plots[display] command. See plot/options for details.
 • frequencyscale=relative or absolute
 This option controls whether the absolute or relative data frequencies are plotted. If frequencyscale is set to relative (the default) then the frequency plot is rescaled to that the area under the plot is equal to 1. Otherwise, the vertical axis gives the exact number of data points in each bin. Using frequencyscale = absolute together with non-constant bin widths (specified using the binbounds option) is not recommended, since the resulting frequency plot may be misleading.
 • averageshifted=posint
 This option specifies how many frequency plots are used to compute the average. The default value is 1. Values other than 1 are only compatible with binbounds = deduce (the default value for that option).
 • binbounds=proportional or list or quantiles(...) or quartiles(...) or deciles(...) or percentiles(...) or deduce
 This option specifies the bounds for each of the bins.
 • binbounds = deduce (the default) specifies that the bins should be equally wide and determined by the bincount, binwidth, maxbins, minbins, and range options. All other values of binbounds override all of these options, unless mentioned otherwise below. This is the only value for binbounds that is compatible with averageshifted being different from 1.
 • binbounds = [x0, x1, ..., xn] with x0 < x1 < ... < xn specifies that numbers given in the list are the boundaries between the bins. So binbounds = [x0, x1, x2, x3] would specify three bins: from x0 to x1, from x1 to x2, and from x2 to x3. Instead of a list, you can also specify a Vector or other one-dimensional rtable.
 • binbounds = quantiles(x0, x1, ..., xn) with 0 <= x0 < x1 < ... < xn <= 1 is equivalent to specifying the list $\left[\mathrm{Quantile}\left(X,\mathrm{x0}\right),\mathrm{Quantile}\left(X,\mathrm{x1}\right),\mathrm{...},\mathrm{Quantile}\left(X,\mathrm{xn}\right)\right]$. See the Quantile help page for details. If the option ignore=true is specified, then it is also passed to the Quantile command.
 • binbounds = quartiles(x0, x1, ..., xn) or deciles(x0, x1, ..., xn) or percentiles(x0, x1, ..., xn) is similar to quantiles(x0, x1, ..., xn), except the commands used are Quartile, Decile, and Percentile, respectively, instead of Quantile.
 • binbounds = proportional determines the bin count in the same way as binbounds = deduce, resulting in, say, $n$ bins. It then proceeds as binbounds = quantiles(0, 1/n, 2/n, ..., 1). Consequently, every bin has roughly the same number of data points in it.
 • range=deduce or range
 The default value is deduce and all available data is used to generate the frequency plot.  If range is specified, all data points outside the given range are ignored.
 • bincount=positive or deduce
 This option controls the number of bins for the histogram. If the number of bins is explicitly specified through this option, the maxbins, minbins, and binwidth options are ignored.
 • binwidth=positive, Sturges, Scott, or FreedmanDiaconis
 This option controls the bin width (and consequently the number of bins) for the frequency plot. The bin width can be either specified explicitly (which overrides the maxbins and minbins options) or can be calculated using one of three methods: Sturges, Scott, or FreedmanDiaconis. The default value is Sturges.
 • maxbins=posint
 This option specifies the maximum number of bins in a frequency plot. If the computed bin width is too small, it will be increased.
 • minbins=posint
 This option specifies the minimum number of bins in a frequency plot. If the computed bin width is too large, it will be decreased.
 • color=name, list, or range
 This option specifies the color of the frequency plot. When a list of colors is given, the colors are used in order for each of the data samples. (In particular, if there is only one data sample, only the first color is used.) When a range of colors is given, the colors are generated by selecting an appropriate number of equally spaced points in the corresponding hue range.
 • discrete=truefalse
 If discrete is set to true, the FrequencyPlot command tallies the data and plots each data point with the corresponding frequency. The default value is false.
 • 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 is ignored.  The default is false.
 • legend=s
 Legend entry for the resulting plot. For information on how to specify s, see plot/typesetting. If s is a list, then it must have as many elements as there are data samples, and the order of the legends corresponds to the order of the datat samples.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Sample}\left(\mathrm{Normal}\left(0,1\right),500\right):$
 > $P≔\mathrm{DensityPlot}\left(\mathrm{Normal}\left(0,1\right),\mathrm{color}="Niagara Red",\mathrm{linestyle}=\mathrm{dash}\right):$
 > $Q≔\mathrm{FrequencyPlot}\left(A,\mathrm{averageshifted}=4\right):$

By default frequencyscale is set to relative.

 > $\mathrm{plots}\left[\mathrm{display}\right]\left(P,Q\right)$

Ordinary frequency plot. This is the command to create the plot from the Plotting Guide using the data above.

 > $\mathrm{FrequencyPlot}\left(A\right)$

Frequency plot where each point represents equally many data points.

 > $\mathrm{FrequencyPlot}\left(A,\mathrm{binbounds}=\mathrm{proportional}\right)$

Misleading frequency plot of the same data where $\mathrm{binbounds}$ specifies bins of different widths and $\mathrm{frequencyscale}=\mathrm{absolute}$.

 > $\mathrm{bounds}≔\left[-\mathrm{\infty },-1,-\frac{1}{2},-\frac{1}{4},-\frac{1}{8},0,\frac{1}{8},\frac{1}{4},\frac{1}{2},1,\mathrm{\infty }\right]$
 ${\mathrm{bounds}}{≔}\left[{-}{\mathrm{\infty }}{,}{-1}{,}{-}\frac{{1}}{{2}}{,}{-}\frac{{1}}{{4}}{,}{-}\frac{{1}}{{8}}{,}{0}{,}\frac{{1}}{{8}}{,}\frac{{1}}{{4}}{,}\frac{{1}}{{2}}{,}{1}{,}{\mathrm{\infty }}\right]$ (1)
 > $\mathrm{FrequencyPlot}\left(A,\mathrm{binbounds}=\mathrm{bounds},\mathrm{frequencyscale}=\mathrm{absolute}\right)$

Other examples:

 > $B≔\mathrm{Sample}\left(\mathrm{Geometric}\left(\frac{1}{3}\right),500\right):$
 > $P≔\mathrm{FrequencyPlot}\left(B,\mathrm{bincount}=10,\mathrm{color}="Niagara Red"\right):$
 > $Q≔\mathrm{Histogram}\left(B,\mathrm{discrete}=\mathrm{true}\right):$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(P,Q\right)$

The following example shows a sample with extreme outliers.

 > $C≔\mathrm{Sample}\left(\mathrm{Cauchy}\left(0,1\right),{10}^{4}\right)$
 ${{\mathrm{_rtable}}}_{{36893628576594174788}}$ (2)
 > $\mathrm{FrequencyPlot}\left(C\right)$

In this case, it is more useful to consider a smaller range.

 > $\mathrm{FrequencyPlot}\left(C,\mathrm{range}=-5..5,\mathrm{binwidth}=\mathrm{FreedmanDiaconis}\right)$

In the next example, FrequencyPlot returns an error because the input includes non-numeric data.  Use the ignore option to see the plot.

 > $\mathrm{FrequencyPlot}\left(\left[1,2,3,\mathrm{undefined}\right]\right)$
 > $\mathrm{FrequencyPlot}\left(\left[1,2,3,\mathrm{undefined}\right],\mathrm{ignore}\right)$

The FrequencyPlot command also accepts a list of data samples, to be plotted individually in the same plot.

 > $A≔\mathrm{Sample}\left(\mathrm{Normal}\left(0,1\right),500\right)$
 ${{\mathrm{_rtable}}}_{{36893628576594192012}}$ (3)
 > $B≔\mathrm{Sample}\left(\mathrm{Normal}\left(1,2\right),500\right)$
 ${{\mathrm{_rtable}}}_{{36893628576594204660}}$ (4)
 > $\mathrm{FrequencyPlot}\left(\left[A,B\right]\right)$

If a Matrix is supplied, then its columns are viewed as independent data samples.

 > $M≔⟨{A}^{\mathrm{%T}}|{B}^{\mathrm{%T}}|{\left(A+B\right)}^{\mathrm{%T}}⟩$
 ${{\mathrm{_rtable}}}_{{36893628576594158284}}$ (5)
 > $\mathrm{FrequencyPlot}\left(M,\mathrm{color}="Niagara Red".."Niagara Blue"\right)$
 > 

Compatibility

 • The binbounds option was introduced in Maple 16.
 • For more information on Maple 16 changes, see Updates in Maple 16.