Resampling Options¶
dFL provides a suite of upsampling (interpolation) and downsampling (block aggregation) methods that can be switched on/off and tuned from the GUIs "Graph Controls" menu.
Upsampling — Interpolation Methods¶
| Method | Order | Monotone? | Typical use |
|---|---|---|---|
| Linear | 1 | ✔ | Fast fill-in, low-noise signals |
| Quadratic | 2 | ✖ | Smooth curves without overshoot |
| Cubic Spline | 3 | ✖ | High-fidelity smoothing of well-behaved data |
| PCHIP (Mono-PCHIP) | 3 | ✔ | Shape-preserving monotone interpolation |
| Akima (Mono-Akima) | 3 | ✔ | Robust monotone interpolation on noisy data |
Linear Interpolation¶
Straight-line segment joining each pair of samples.
Pros – Fast, memory-light, never overshoots.
Cons – Corners at sample points; poor on curved signals.
References
- SciPy Interpolation Guide — “Linear Interpolation.” [SciPy]
Quadratic Interpolation¶
Piecewise parabolas pass through consecutive triplets of points.
Pros – Smoother than linear with modest cost.
Cons – Can introduce mild overshoot or wiggle.
References
- J. Stoer & R. Bulirsch, Introduction to Numerical Analysis, § 2.3. [Springer]
Cubic Spline Interpolation¶
Joins samples with \(C^{2}\)-continuous cubic polynomials, minimizing overall curvature.
Pros – Very smooth (\(C^{2}\)); excellent for graphics & contours.
Cons – Possible ringing near steep gradients; not monotonic.
References
- C. de Boor, A Practical Guide to Splines, ch. 4. [Springer]
- SciPy — “Cubic (‘cubic’) interpolation.” [SciPy]
Piecewise Cubic Hermite (PCHIP) — Mono-PCHIP¶
Shape-preserving Hermite cubic; guarantees monotonicity between samples.
Pros – No overshoot; honors monotone trends; good for cumulative curves.
Cons – Slightly less smooth than cubic spline (\(C^{1}\) only).
References
- Fritsch & Carlson, “Monotone Piecewise Cubic Interpolation,” SIAM J. Numer. Anal. 17 (2), 1980. [DOI]
- SciPy — PchipInterpolator. [SciPy]
Akima Interpolation — Mono-Akima¶
Locally weighted cubic polynomials; monotone without requiring derivative estimates.
Pros – Handles outliers gracefully; minimal ringing; monotone.
Cons – Slightly higher cost than PCHIP.
References
- T. Akima, “A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures,” J. ACM 17 (4), 1970. [ACM]
- SciPy — Akima1DInterpolator. [SciPy]
Downsampling — Block Aggregation Methods¶
It is worth noting that downsampling is generally a non-invertible transformation.
| Method | Operation | Good for |
|---|---|---|
Block Average (block_avg) |
Mean of each non-overlapping window | Anti-alias decimation, smooth trends |
Block Max (block_max) |
Maximum in window | Peak-holding monitors, envelopes |
Block Min (block_min) |
Minimum in window | Valley detection, envelope inversion |
MLE GMM (mle_gmm) |
Maximum-likelihood value from a Gaussian Mixture fit per window | Multi-modal or clustered data |
Importance (importance) |
Importance downsampling based on central mmoments per window | Preserving statistics |
Block Average¶
Partitions the signal into fixed-length blocks and replaces each by its mean.
Pros – Simple anti-alias filter; preserves energy on white-noise signals.
Cons – Blurs sharp peaks; sensitive to window alignment.
References
- S. W. Smith, The Scientist & Engineer’s Guide to DSP, ch. 12 “Multirate DSP.” Free PDF
- Uniform 1-D box filtering. SciPy Docs
Block Max¶
Replaces each block with its maximum value.
Pros – Captures worst-case peaks; useful for overload monitoring.
Cons – Loses average information; sensitive to outliers.
References
- 1-D maximum (dilation) filters. SciPy Docs
Block Min¶
Replaces each block with its minimum value.
Pros – Tracks valleys; complements block max for envelope bounds.
Cons – Discards peak information; susceptible to negative spikes.
References
- 1-D minimum (erosion) filters. SciPy Docs
MLE GMM (Maximum-Likelihood Gaussian Mixture)¶
- Partition the sequence \(\{x_j\}_{j=1}^{N}\) into non‑overlapping bins of size \(k\).
- Fit Gaussian‑mixture models with component counts \(i = 1,\dots,n\) to the \(k\) samples in each bin.
- Select the optimal component count \(i_0\) by minimizing the Bayesian Information Criterion, \( \text{BIC} = -2\log\mathcal{L} + p\log k \), where \(\mathcal{L}\) is the likelihood and \(p\) is the number of free parameters.
- Compute the maximum‑likelihood value, \( \hat{x} = \arg\max_{x}\,P(x \mid \theta_{i_0}) \), where \(P(x \mid \theta_{i_0})\) is the PDF of the selected GMM.
- Output \(\hat{x}\) as the representative for that bin; repeat for all bins.
Pros
- Preserves multi‑modal structure (variance, skew, clusters) that averaging would erase.
- Adapts the model order via BIC—no manual choice of component count.
- Useful for non‑Gaussian or clustered signals when \(k \ge 30\).
Cons
- Computationally heavy (iterative Expectation–Maximization per bin).
- Sensitive to initialization; may converge to local optima.
- Falls back to simple averaging for small blocks (\(k < 30\)).
- If the local distribution is not well modeled by Gaussian Mixtures, results may degrade.
References
- G. McLachlan & D. Peel, Finite Mixture Models. Wiley, 2000. https://www.wiley.com/en-us/Finite+Mixture+Models-p-9780471006268
- K. P. Murphy, Machine Learning: A Probabilistic Perspective, § 11 (Mixture Models). MIT Press, 2012. https://mitpress.mit.edu/9780262018029/machine-learning/
- scikit‑learn User Guide — Gaussian Mixture & BIC/AIC model selection. https://scikit-learn.org/stable/modules/mixture.html#model-selection
Importance Downsampling¶
Selects values in each block so that chosen central moments (variance, skewness, kurtosis, …) match those of the original data and the samples remain close to their original time stamps.
Note: the mean is a raw moment and is not preserved by this method. Also it should be noted that importance sampling can be computationally expensive.
Automatic fallback
If a block has fewer than (k + 1) points (not enough to satisfy the requested moment set), the Labeler automatically reverts to Block Average for that window.
Procedure
- Partition the signal into non-overlapping bins of size \(k\).
- Define a target central moment vector \(m=[\mu_2^c,\mu_3^c,\dots,\mu_r^c]=[2,3,\dots,c]\), where
- \(\mu_2^c = \mathbb{E}[(x - \bar{x})^2]\) (variance),
- \(\mu_3^c = \mathbb{E}[(x - \bar{x})^3]\) (skewness),
- \(\mu_4^c = \mathbb{E}[(x - \bar{x})^4]\) (kurtosis), etc.
-
Formulate an objective that penalizes central-moment error plus temporal error:
\[J(\mathbf{y})=\sum_j\left(\frac{\hat\mu_j^c-\mu_j^c}{|\mu_j^c|+10^{-8}}\right)^2 +\lambda\sum_i(y_i-\tilde{x}_i)^2,\]where \(\hat\mu_j^c\) are estimated central moments of the candidate values \(\mathbf{y}\) and \(\tilde{x}_i\) are mid-points of the bin.
4. Optimize \(J(\mathbf{y})\) with L-BFGS-B, constraining each \(y_i\) to remain within the min/max of its block.
5. Output the optimized \(\mathbf{y}\) as the block’s representatives; repeat for all blocks.
Pros
- Explicitly preserves user-selected central moments (variance, skewness, kurtosis, …).
- Temporal penalty keeps representatives close to their original times.
- Adaptive: each block can receive a different moment-matching solution.
Cons
- Requires at least \((k + 1)\) samples per block; otherwise falls back to averaging.
- Computationally heavy (non-linear optimization per block).
- Sensitive to initial guess; may converge to local minima.
- Central-moment matching alone does not guarantee frequency fidelity.
References
- D. Faghihi et al., “A Moment Preserving Constrained Resampling (MPCR) Algorithm for Particle-in-Cell Simulations,” Journal of Computational Physics, 2020.
- T. Paananen & A. Vehtari, “Implicitly Adaptive Importance Sampling: Importance Weighted Moment Matching,” Statistics and Computing, 2021.