Categories &

Functions List

Class Definition: prob.KernelDistribution

statistics: prob.KernelDistribution

Kernel probability distribution object.

A prob.KernelDistribution object consists of a nonparametric kernel smoothing density estimate fitted to sample data, together with a model description. Unlike the parametric distribution objects, it has no estimated parameters; the fitted distribution is defined entirely by the data, the smoothing kernel, and the bandwidth.

A prob.KernelDistribution object can only be created by fitting a kernel smoothing distribution to data with the fitdist function. Unlike the parametric distributions, it cannot be created with the makedist function, since it is not parametric and requires data.

Further information about the kernel density estimation can be found at https://en.wikipedia.org/wiki/Kernel_density_estimation

See also: fitdist, ksdensity, mvksdensity

Source Code: prob.KernelDistribution

The prob.KernelDistribution class contains the following properties:

A character vector specifying the name of the probability distribution object. This property is read-only.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A character vector specifying the type of smoothing kernel used for the density estimate. It is one of 'normal', 'box', 'triangle', or 'epanechnikov'. You can access the Kernel property using dot name assignment.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A positive scalar value specifying the bandwidth of the smoothing kernel. You can access the Bandwidth property using dot name assignment.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A scalar structure containing the following fields:

  • range: either the character vector 'unbounded' or 'positive', or a two-element numeric vector [L, U] with the lower and upper bounds of the support.
  • closedbound: a two-element logical vector specifying whether each bound is closed.
  • iscontinuous: a logical scalar, always true for a kernel distribution.

This property is read-only.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A 1×2 numeric vector specifying the truncation interval for the probability distribution. First element contains the lower boundary, second element contains the upper boundary. This property is read-only. You can only truncate a probability distribution with the truncate method.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A logical scalar value specifying whether a probability distribution is truncated or not. This property is read-only.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

A scalar structure containing the following fields:

  • data: a numeric vector containing the data used for distribution fitting.
  • cens: an empty array, since censoring is not supported for a kernel distribution.
  • freq: a numeric vector of non-negative integer values containing the frequency information corresponding to the elements of the data used for distribution fitting. If no frequency vector was used for distribution fitting, then this field defaults to an empty array.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

The prob.KernelDistribution class offers the following public methods:

prob.KernelDistribution: p = cdf (pd, x)
prob.KernelDistribution: p = cdf (pd, x, 'upper')

p = cdf (pd, x) computes the CDF of the probability distribution object, pd, evaluated at the values in x.

p = cdf (…, 'upper') returns the complement of the CDF of the probability distribution object, pd, evaluated at the values in x.

x must be double or single; integer, logical, and character arrays are rejected.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: x = icdf (pd, p)

x = icdf (pd, p) computes the quantile (the inverse of the CDF) of the probability distribution object, pd, evaluated at the values in p.

p must be double or single; integer, logical, and character arrays are rejected.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: r = iqr (pd)

r = iqr (pd) computes the interquartile range of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: m = mean (pd)

m = mean (pd) computes the mean of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: m = median (pd)

m = median (pd) computes the median of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: nlogL = negloglik (pd)

nlogL = negloglik (pd) computes the negative loglikelihood of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: y = pdf (pd, x)

y = pdf (pd, x) computes the PDF of the probability distribution object, pd, evaluated at the values in x.

x must be double or single; integer, logical, and character arrays are rejected.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: plot (pd)
prob.KernelDistribution: plot (pd, Name, Value)
prob.KernelDistribution: h = plot (…)

plot (pd) plots a probability density function (PDF) of the probability distribution object pd, superimposed over a histogram of the data used to fit it.

plot (pd, Name, Value) specifies additional options with the Name-Value pair arguments listed below.

NameValue
'PlotType'A character vector specifying the plot type. 'pdf' plots the probability density function (PDF) superimposed on a histogram of the data. 'cdf' plots the cumulative distribution function (CDF) superimposed over an empirical CDF. 'probability' plots a probability plot using a CDF of the data and a CDF of the fitted probability distribution.
'Parent'An axes graphics object for plot. If not specified, the plot function plots into the current axes or creates a new axes object if one does not exist.

h = plot (…) returns a graphics handle to the plotted objects.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: r = random (pd)
prob.KernelDistribution: r = random (pd, rows)
prob.KernelDistribution: r = random (pd, rows, cols, …)
prob.KernelDistribution: r = random (pd, [sz])

r = random (pd) returns a random number from the distribution object pd.

When called with a single size argument, random returns a square matrix with the dimension specified. When called with more than one scalar argument, the first two arguments are taken as the number of rows and columns and any further arguments specify additional matrix dimensions. The size may also be specified with a row vector of dimensions, sz.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: s = std (pd)

s = std (pd) computes the standard deviation of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: t = truncate (pd, lower, upper)

t = truncate (pd, lower, upper) returns a probability distribution t, which is the probability distribution pd truncated to the specified interval with lower limit, lower, and upper limit, upper.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

prob.KernelDistribution: v = var (pd)

v = var (pd) computes the variance of the probability distribution object, pd.

Fit a kernel distribution to a sample and plot its PDF over a histogram.

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure

Examples

 load patients
 pd = fitdist (Weight, 'Kernel');
 plot (pd)
 title ('Kernel distribution fitted to patient weights')
plotted figure