Kernel Density.Fit Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0
public static KernelDensityEstimate Fit(
Vector<double> input,
KernelDensityOptions? options = null,
Vector<double>? weights = null
)Parameters
- input Vector<Double>
- A nonempty vector of finite observations, including any zero-weight entries.
- options KernelDensityOptions (Optional)
- Kernel and bandwidth settings, or null for Gaussian normal-reference selection.
- weights Vector<Double> (Optional)
- Finite nonnegative relative masses matched by position to the observations, or null for equal mass. At least one mass must be positive.
Return Value
KernelDensityEstimateA fitted estimate owning snapshots of the observations and weights and the resolved bandwidth.
Remarks
Input vectors and labels are not modified. Zero-weight observations do not affect evaluation, grid bounds, bandwidth selection or sampling. Common weight scaling does not change the fit. Weights are relative masses, rather than replication counts.
Automatic selection uses effective sample size and weighted population spread. Weighted quartiles interpolate Weibull plotting positions as described in the KDE guide. Equal positive weights preserve the existing unweighted bandwidth convention. At least two positive-weight observations with positive spread are required; fixed bandwidth also permits a single observation or constant data.
Bandwidth adjustment is applied once. Custom kernel delegates must remain stable and safe for concurrent calls.
Exceptions
| Argument | input is null. |
| Argument | Observations or weights are invalid or unsuitable for automatic bandwidth selection. |
| Argument | The selected or adjusted bandwidth is not finite and positive. |
| Invalid | The kernel normalization is not finite and positive. |
| Not | The kernel does not support the requested bandwidth rule. |