KernelDensity.Estimate Method

Definition

Namespace: Numerics.NET.Statistics
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0

Overload List

Estimate(Vector<Double>, Vector<Double>, Double, Func<Double, Double>)

Estimates densities at supplied points using a normalized custom kernel.
C#
public static Vector<double> Estimate(
	Vector<double> input,
	Vector<double> values,
	double bandwidth,
	Func<double, double> kernel
)

Parameters

input  Vector<Double>
Nonempty finite observations with equal weights.
values  Vector<Double>
Query coordinates in any order, including an empty vector.
bandwidth  Double
A finite positive width in observation units.
kernel  Func<Double, Double>
A nonnegative function integrating to one over the real line. Return zero outside its support, including at infinite arguments.

Return Value

Vector<Double>
A new vector of densities in query order, preserving the query labels. NaN queries produce NaN; infinite queries produce zero.

Remarks

The delegate is used as supplied: normalization, nonnegativity and support are not checked or inferred. It must remain stable throughout evaluation. Do not modify observations or queries during evaluation. Single and constant observations are permitted. Densities are evaluated directly and are not renormalized over the query coordinates. Exceptions from the delegate propagate to the caller.

Exceptions

ArgumentNullExceptionThe observations, queries or kernel delegate are null.
ArgumentExceptionThe observations are empty or nonfinite.
ArgumentOutOfRangeExceptionThe bandwidth is not finite and positive.

Estimate(Vector<Double>, Double, Double, Func<Double, Double>)

Estimates the density at one point using a normalized custom kernel.
C#
public static double Estimate(
	Vector<double> input,
	double value,
	double bandwidth,
	Func<double, double> kernel
)

Parameters

input  Vector<Double>
Nonempty finite observations with equal weights.
value  Double
The coordinate at which to estimate the density.
bandwidth  Double
A finite positive width in observation units.
kernel  Func<Double, Double>
A nonnegative function integrating to one over the real line. Return zero outside its support, including at infinite arguments.

Return Value

Double
The density, NaN for a NaN query, or zero for an infinite query.

Remarks

See the vector-query overload for the full custom-kernel contract.

Estimate(Vector<Double>, Kernel, Vector<Double>, Double, KernelDensityBandwidthEstimator, Double)

Estimates the density of the input
C#
public static Vector<double> Estimate(
	Vector<double> input,
	Kernel kernel,
	Vector<double> values,
	double bandwidth = NaN,
	KernelDensityBandwidthEstimator bandwidthEstimator = KernelDensityBandwidthEstimator.NormalReference,
	double bandwidthAdjustment = 1
)

Parameters

input  Vector<Double>
kernel  Kernel
The kernel to use for the estimation.
values  Vector<Double>
The value at which to estimate the density.
bandwidth  Double  (Optional)
Optional. The bandwidth.
bandwidthEstimator  KernelDensityBandwidthEstimator  (Optional)
Optional. The method used to compute the bandwidth.
bandwidthAdjustment  Double  (Optional)
Optional. A factor by which to adjust the bandwidth.

Return Value

Vector<Double>
A vector containing the estimated density at values.

Remarks

When bandwidth is supplied, it is used as the bandwidth, and the value of bandwidthEstimator is ignored. Otherwise, the method specified by bandwidthEstimator is used to estimate the bandwidth. The default is to use the normal reference bandwidth, which minimizes the integrated square error under the assumption that the data is normal.

The bandwidth is multiplied by the bandwidthAdjustment, with a default value of 1. This makes it possible to specify a bandwidth as a fraction of the estimated bandwidth.

Exceptions

ArgumentNullException

input is null.

-or-

kernel is null.

-or-

values is null.

Estimate(Vector<Double>, Kernel, Double, Double, KernelDensityBandwidthEstimator, Double)

Estimates the density of the input
C#
public static double Estimate(
	Vector<double> input,
	Kernel kernel,
	double value,
	double bandwidth = NaN,
	KernelDensityBandwidthEstimator bandwidthEstimator = KernelDensityBandwidthEstimator.NormalReference,
	double bandwidthAdjustment = 1
)

Parameters

input  Vector<Double>
kernel  Kernel
The kernel to use for the estimation.
value  Double
The value at which to estimate the density.
bandwidth  Double  (Optional)
Optional. The bandwidth.
bandwidthEstimator  KernelDensityBandwidthEstimator  (Optional)
Optional. The method used to compute the bandwidth.
bandwidthAdjustment  Double  (Optional)
Optional. A factor by which to adjust the bandwidth.

Return Value

Double
The estimated density at value.

Remarks

When bandwidth is supplied, it is used as the bandwidth, and the value of bandwidthEstimator is ignored. Otherwise, the method specified by bandwidthEstimator is used to estimate the bandwidth. The default is to use the normal reference bandwidth, which minimizes the integrated square error under the assumption that the data is normal.

The bandwidth is multiplied by the bandwidthAdjustment, with a default value of 1. This makes it possible to specify a bandwidth as a fraction of the estimated bandwidth.

Exceptions

ArgumentNullException

input is null.

-or-

kernel is null.

Estimate(Vector<Double>, Kernel, Int32, Double, Double, Double, Double, KernelDensityBandwidthEstimator, Double)

Estimates the density of the input.
C#
public static Vector<double> Estimate(
	Vector<double> input,
	Kernel kernel,
	int dataPoints = -1,
	double lowerBound = NaN,
	double upperBound = NaN,
	double padding = 3,
	double bandwidth = NaN,
	KernelDensityBandwidthEstimator bandwidthEstimator = KernelDensityBandwidthEstimator.NormalReference,
	double bandwidthAdjustment = 1
)

Parameters

input  Vector<Double>
kernel  Kernel
The kernel to use for the estimation.
dataPoints  Int32  (Optional)
Optional. The number of data points to use in the approximation.
lowerBound  Double  (Optional)
Optional. The lower bound of the interval where the density should be approximated.
upperBound  Double  (Optional)
Optional. The upper bound of the interval where the density should be approximated.
padding  Double  (Optional)
Optional. The space before the smallest element in input and after the largest element in input where the probability density should be approximated in units of the bandwidth. The default value is 3.
bandwidth  Double  (Optional)
Optional. The bandwidth.
bandwidthEstimator  KernelDensityBandwidthEstimator  (Optional)
Optional. The method used to compute the bandwidth.
bandwidthAdjustment  Double  (Optional)
Optional. A factor by which to adjust the bandwidth.

Return Value

Vector<Double>
A vector containing the estimated density at dataPoints equally spaced points extending padding bandwidths past the lowest and largest values in input.

Remarks

When bandwidth is supplied, it is used as the bandwidth, and the value of bandwidthEstimator is ignored. Otherwise, the method specified by bandwidthEstimator is used to estimate the bandwidth. The default is to use the normal reference bandwidth, which minimizes the integrated square error under the assumption that the data is normal.

The bandwidth is multiplied by the bandwidthAdjustment, with a default value of 1. This makes it possible to specify a bandwidth as a fraction of the estimated bandwidth.

If lowerBound or upperBound are not supplied, they are calculated by extending the range of input by padding times the bandwidth.

Exceptions

ArgumentNullException

input is null.

-or-

kernel is null.

See Also