Weight Functions
Kernel functions for distance weighting.
Overview
Weight functions (kernels) determine how neighboring points contribute to each local fit. Points closer to the target receive higher weights.
Available Kernels
Kernel
Efficiency
Smoothness
Support
Tricube
0.998
Very smooth
Compact
Epanechnikov
1.000
Smooth
Compact
Gaussian
0.961
Infinite
Unbounded
Biweight
0.995
Very smooth
Compact
Cosine
0.999
Smooth
Compact
Triangle
0.989
Moderate
Compact
Uniform
0.943
None
Compact
Efficiency = AMISE relative to Epanechnikov (1.0 = optimal)
Tricube (Default)
Cleveland's original choice. Best all-around performance.
\[w(u) = (1 - |u|^3)^3\]
Use when : Default choice for most applications.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "tricube" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "tricube" )
let model = Lowess :: new ()
. weight_function ( Tricube )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "tricube" )
const result = smooth ( x , y , { weightFunction : "tricube" });
const result = smooth ( x , y , { weightFunction : "tricube" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "tricube" });
Epanechnikov
Theoretically optimal for kernel density estimation.
\[w(u) = \frac{3}{4}(1 - u^2)\]
Use when : Optimal MSE properties desired.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "epanechnikov" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "epanechnikov" )
let model = Lowess :: new ()
. weight_function ( Epanechnikov )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "epanechnikov" )
const result = smooth ( x , y , { weightFunction : "epanechnikov" });
const result = smooth ( x , y , { weightFunction : "epanechnikov" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "epanechnikov" });
Gaussian
Infinitely smooth. No boundary effects.
\[w(u) = \exp(-u^2/2)\]
Use when : Maximum smoothness needed, computational cost acceptable.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "gaussian" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "gaussian" )
let model = Lowess :: new ()
. weight_function ( Gaussian )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "gaussian" )
const result = smooth ( x , y , { weightFunction : "gaussian" });
const result = smooth ( x , y , { weightFunction : "gaussian" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "gaussian" });
Biweight
Good balance of efficiency and smoothness.
\[w(u) = (1 - u^2)^2\]
Use when : Alternative to Tricube with slightly different properties.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "biweight" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "biweight" )
let model = Lowess :: new ()
. weight_function ( Biweight )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "biweight" )
const result = smooth ( x , y , { weightFunction : "biweight" });
const result = smooth ( x , y , { weightFunction : "biweight" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "biweight" });
Cosine
Smooth and computationally efficient.
\[w(u) = \cos(\pi u / 2)\]
Use when : Want smooth kernel with simple form.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "cosine" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "cosine" )
let model = Lowess :: new ()
. weight_function ( Cosine )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "cosine" )
const result = smooth ( x , y , { weightFunction : "cosine" });
const result = smooth ( x , y , { weightFunction : "cosine" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "cosine" });
Triangle
Simple linear taper.
\[w(u) = 1 - |u|\]
Use when : Simple, interpretable weights.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "triangle" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "triangle" )
let model = Lowess :: new ()
. weight_function ( Triangle )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "triangle" )
const result = smooth ( x , y , { weightFunction : "triangle" });
const result = smooth ( x , y , { weightFunction : "triangle" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "triangle" });
Equal weights within window. Fastest but least smooth.
\[w(u) = 1\]
Use when : Speed is critical, smoothness less important.
R Python Rust Julia Node.js WebAssembly C++
result <- Lowess ( weight_function = "uniform" ) $ fit ( x , y )
result = fl . smooth ( x , y , weight_function = "uniform" )
let model = Lowess :: new ()
. weight_function ( Uniform )
. adapter ( Batch )
. build () ? ;
result = smooth ( x , y , weight_function = "uniform" )
const result = smooth ( x , y , { weightFunction : "uniform" });
const result = smooth ( x , y , { weightFunction : "uniform" });
auto result = fastlowess :: smooth ( x , y , { . weight_function = "uniform" });
Choosing a Kernel
flowchart TD
A[Choose Kernel] --> B{Need maximum smooth}
B -- Yes --> C[Gaussian]
B -- No --> D{Default acceptable}
D -- Yes --> E[Tricube]
D -- No --> F{Optimal MSE}
F -- Yes --> G[Epanechnikov]
F -- No --> H{Speed critical}
H -- Yes --> I[Uniform]
H -- No --> J[Biweight]
Recommendation
Stick with Tricube (default) unless you have specific requirements. The differences between kernels are usually small in practice.