Main Content

KernelDistribution

Kernel probability distribution object

Description

A KernelDistribution object consists of parameters, a model description, and sample data for a nonparametric kernel-smoothing distribution.

The kernel distribution is a nonparametric estimation of the probability density function (pdf) of a random variable.

The kernel distribution uses the following options.

OptionDescriptionPossible Values
KernelKernel function typenormal, box, triangle, epanechnikov
BandwidthKernel smoothing parameterBandwidth > 0

Creation

There are several ways to create a KernelDistribution probability distribution object.

Properties

expand all

Distribution Parameters

Kernel function type, specified as a valid kernel function type name.

Bandwidth of the kernel smoothing window, specified as a positive scalar value.

Data Types: single | double

Distribution Characteristics

This property is read-only.

Logical flag for a truncated distribution, represented as 0 or 1. If IsTruncated is 0, the distribution is not truncated. If IsTruncated is 1, the distribution is truncated.

Data Types: logical

This property is read-only.

Truncation interval for the probability distribution, represented as a vector of numeric scalars containing the lower and upper truncation boundaries.

Data Types: single | double

Other Object Properties

This property is read-only.

Probability distribution name, represented as a character vector.

Data Types: char

This property is read-only.

Data used for distribution fitting, represented as a structure containing the following:

  • data – Data vector used for distribution fitting

  • cens – Censoring vector (empty if none)

  • freq – Frequency vector (empty if none)

Data Types: struct

Object Functions

cdfCumulative distribution function
gatherGather properties of Statistics and Machine Learning Toolbox object from GPU
icdfInverse cumulative distribution function
iqrInterquartile range of probability distribution
meanMean of probability distribution
medianMedian of probability distribution
negloglikNegative loglikelihood of probability distribution
pdfProbability density function
plotPlot probability distribution object
randomRandom numbers
stdStandard deviation of probability distribution
truncateTruncate probability distribution object
varVariance of probability distribution

Examples

collapse all

Load the sample data.

load carsmall

The variable MPG contains data for car gas mileage.

Create a probability distribution object by fitting a kernel distribution to MPG.

pd = fitdist(MPG,"Kernel")
pd = 
  KernelDistribution

    Kernel = normal
    Bandwidth = 4.11428
    Support = unbounded

pd is a probability distribution object with properties that include specifications for the kernel smoother type, bandwidth of the kernel smoothing window, and input data.

Plot the kernel pdf with a histogram of the input data.

plot(pd)

Figure contains an axes object. The axes object with xlabel Data, ylabel PDF contains 2 objects of type histogram, line.

The plot shows the pdf of the kernel distribution fit to the MPG data. The distribution is smooth and slightly skewed with a heavier right tail.

Extended Capabilities

expand all

Version History

Introduced in R2013a