pip install numpy
# Then copy epa_smoothing.py to your project
epanechnikov_kernel(u)Compute Epanechnikov kernel weights.
| Parameter | Type | Description |
|---|---|---|
u | np.ndarray | Scaled distances (x - x0) / bandwidth |
Returns: np.ndarray - Kernel weights (0 for |u| > 1)
weighted_median(values, weights)Compute weighted median of values.
| Parameter | Type | Description |
|---|---|---|
values | np.ndarray | Data values |
weights | np.ndarray | Non-negative weights |
Returns: float - Weighted median value
silverman_bandwidth(x)Automatic bandwidth selection using Silverman's rule.
| Parameter | Type | Description |
|---|---|---|
x | np.ndarray | Input x-coordinates |
Returns: float - Recommended bandwidth
epa_local_median(x, y, bandwidth)EPA kernel-weighted local median smoother.
| Parameter | Type | Description |
|---|---|---|
x | np.ndarray | Input x-coordinates |
y | np.ndarray | Input y-values (noisy) |
bandwidth | float | Kernel bandwidth (controls smoothness) |
Returns: np.ndarray - Smoothed y-values
epa_local_mean(x, y, bandwidth)EPA kernel-weighted local mean smoother (Nadaraya-Watson).
| Parameter | Type | Description |
|---|---|---|
x | np.ndarray | Input x-coordinates |
y | np.ndarray | Input y-values |
bandwidth | float | Kernel bandwidth |
Returns: np.ndarray - Smoothed y-values