KernelDensityPlot - Maple Help

Statistics

 KernelDensityPlot
 plot the kernel density estimate of a data set

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

Parameters

 X - options - (optional) equation(s) of the form option=value where option is one of bandwidth, bins, ignore, kernel, left, method, range, right, weights, or any standard plot options; specify options for the KernelDensityPlot command plotoptions - options to be passed to the plots[display] command

Description

 • The KernelDensityPlot command plots the kernel density estimate for a data sample.
 • The first parameter X is a single data sample - given as e.g. a Vector.
 • 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.
 • bandwidth=realcons
 The bandwidth is a positive quantity that specifies the width of the kernel (the amount each data point affects distant portions of the probability density estimate).  Each kernel is scaled such that the bandwidth is equal to the standard deviation of the kernel.
 • bins=posint
 The number of bins in which to categorize data points (512 by default). This value must be a power of 2 and is equal to the size of the array returned from the routine when the option method=piecewise is specified.  This parameter is ignored if method=exact.
 • 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 are ignored.
 • kernel=gaussian, biweight, epanechnikov, triangular, or rectangular
 The default value is gaussian.  This option allows a non-Gaussian kernel to be used in developing the estimate. For more information, see Statistics[KernelDensity].
 • left=realcons
 This option specifies the lower boundary on valid data values. Any data values that are smaller than this value are discarded.  By default, this procedure imposes boundary conditions consistent with the specified range rng.
 • method=exact or piecewise
 This parameter specifies the method of plotting the kernel density estimate (by default this is piecewise).  For more information, see Statistics[KernelDensity].
 • range=deduce or realrange
 By default this is deduce.  This option is used to bound the horizontal real range on which the kernel density estimate is plotted.
 • right=realcons
 This option specifies the upper boundary on valid data values. Any data values that are smaller than this value are discarded.  By default, this procedure imposes boundary conditions consistent with the specified range rng.
 • weights=rtable
 Vector of weights (one-dimensional rtable). If weights are given, the kernel density estimate is scaled so each data point has the given weight. Note that the weights provided must have type realcons and the results 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.

Notes

 • Note that the discrete case of kernel density estimation employs a discrete Fourier transform in order to calculate the kernel sums as quickly as possible.  However, this results in an estimating function which is periodic over the range left..right.  Hence estimates near these lower and upper boundaries of the range are often more imprecise than points within this range.
 • Note that points that do not fall into the range left..right and missing data are not considered for this operation and are normally discarded.  If ignore=false and this procedure encounters missing data, it will spawn a userinfo message.
 • Note that all options specified in calling this command that are not parsed by KernelDensity are then passed to plot.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$

Plot the kernel density estimate of a data sample.

 > $S≔\mathrm{Sample}\left(\mathrm{Normal}\left(0,1\right),100000\right):$
 > $\mathrm{KernelDensityPlot}\left(S,\mathrm{range}=-5..5,\mathrm{bins}=512,\mathrm{kernel}=\mathrm{biweight},\mathrm{method}=\mathrm{piecewise}\right)$

The command to create the plot from the Plotting Guide is

 > $A≔\mathrm{Array}\left(\left[-1.,-0.4,-0.2,0.,0.,0.1,0.2,0.7,0.9\right]\right)$
 $\left[\begin{array}{ccccccccc}-1.& -0.4& -0.2& 0.& 0.& 0.1& 0.2& 0.7& 0.9\end{array}\right]$ (1)
 > $\mathrm{KernelDensityPlot}\left(A,\mathrm{range}=-5..5,\mathrm{bins}=512,\mathrm{bandwidth}=\frac{1}{4},\mathrm{kernel}=\mathrm{biweight},\mathrm{method}=\mathrm{exact}\right)$