Polynomial Baselines


In 2D, a polynomial can be expressed as

\[p(x, z) = \sum\limits_{i = 0}^{d_r} \sum\limits_{j = 0}^{d_c} {\beta_{i, j} x^i z^j}\]

where \(\beta\) is the matrix of coefficients for the polynomial and \(d_r\) and \(d_c\) are the polynomial degrees for the rows (\(x\)) and columns (\(z\)), respectively.

For regular polynomial fitting, the polynomial coefficients that best fit data are gotten from minimizing the least-squares:

\[\sum\limits_{i}^M \sum\limits_{j}^N w_{ij}^2 (y_{ij} - p(x_i, z_j))^2\]

where \(y_{ij}\), \(x_i\), and \(z_j\) are the measured data, \(p(x_i, z_j)\) is the polynomial estimate at \(x_i\), and \(z_j\) and \(w_{ij}\) is the weighting.

However, since only the baseline of the data is desired, the least-squares approach must be modified. For polynomial-based algorithms, this is done by 1) only fitting the data in regions where there is only baseline, 2) modifying the y-values being fit each iteration, or 3) penalyzing outliers.


For two dimensional data, polynomial algorithms take a single poly_order parameter that can either be a single number, in which case both the rows and columns will use the same polynomial degree, ie. \(d_r = d_c\), or a sequence of two numbers (\(d_r\), \(d_c\)) to use different polynomials along the rows and columns. Further, max_cross can be set to limit the polynomial coefficients for the cross terms.


poly (Regular Polynomial)

poly(): explanation for the algorithm. No plot will be shown since it is just a simple least-squares polynomial fitting.

modpoly (Modified Polynomial)

modpoly(): explanation for the algorithm.

(Source code)





imodpoly (Improved Modified Polynomial)

imodpoly(): explanation for the algorithm.

(Source code)





penalized_poly (Penalized Polynomial)

penalized_poly(): explanation for the algorithm.

(Source code)





quant_reg (Quantile Regression)

quant_reg(): explanation for the algorithm.

(Source code)