Statistics[KernelDensitySample] - sample a kernel density estimate
|
Calling Sequence
|
|
KernelDensitySample(data, n, options)
|
|
Parameters
|
|
data
|
-
|
rtable; data sample
|
n
|
-
|
n; size of output sample
|
options
|
-
|
(optional) equation(s) of the form option=value where option is one of kernel, bandwidth, bins, left, right, ignore or weights; specify options for the KernelDensitySample function
|
|
|
|
|
Description
|
|
•
|
The KernelDensitySample function creates a probability density function for the data using kernel density estimation and then uses the resulting probability density as a basis for drawing a random sample. The resulting data is thus very similar to the original data.
|
•
|
The first parameter data is the data set, which must be a one-dimensional rtable (e.g. Array or Vector).
|
•
|
The second parameter n is the size of the output sample, which must be a positive integer.
|
|
|
Options
|
|
|
The options argument can contain one or more of the options shown below.
|
•
|
kernel = 'gaussian', 'biweight', 'epanechnikov', 'triangular', 'rectangular' -- By default this is 'gaussian'. This option allows a non-gaussian kernel to be used in developing the estimate. The gaussian and biweight kernels are smooth - if they are used no sharp edges will be present in the final estimate. The epanechnikov kernel is often considered to be the optimal kernel. The triangular and rectangular kernels are sharp kernels - they will impose sharp edges in the final estimate.
|
•
|
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). The number of bins determines the accuracy of the kernel density estimate.
|
•
|
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 the algorithm attempts to determine the minimum value in the data set and further includes padding of width 3*bandwidth.
|
•
|
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 the algorithm attempts to determine the maximum value in the data set and further includes padding of width 3*bandwidth.
|
•
|
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 data will be ignored.
|
•
|
weights = rtable -- Vector of weights (one-dimensional rtable). If weights are given, the KernelDensitySample function will weight each data point accordingly. Note that the weights provided must have type,realcons and the results are floating-point, even if the problem is specified with exact values. The data array and the weights array must have the same number of elements.
|
|
|
Notes
|
|
•
|
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.
|
|
|
Examples
|
|
>
|
|
Sample similar points from a distribution given by an array.
>
|
|
| (1) |
>
|
|
| (2) |
Sample from a distribution similar to the exponential of a normal distribution by remapping points generated by the normal distribution.
>
|
|
>
|
|
>
|
|
>
|
|
| (3) |
|
|
Download Help Document
Was this information helpful?