zmzhang/airPLS

weighting equation discrepancy

burgerrg opened this issue · 2 comments

The R & Python code for computing the weight vector (e.g., https://github.com/zmzhang/airPLS/blob/a92b37a7bcc4d22eac02db2ebdb0a1b9ce1a1a55/airPLS.py#L81-L83C19) appear to differ from the equation given in the paper:

  • The code uses e^(t * abs(x_i - z_i) / abs_d), which is e^(t * (z_i - x_i) / abs_d), not e^(t * (x_i - z_i) / abs_d) that the paper says.
  • The code uses a special value for w_1 and w_m based on the max negative deviation, which is by definition negative.

The code thus weights points with a lower value more highly, whereas the paper does the opposite. I don't know why the code uses a value for the first and last weights that raises e to a negative power.

@burgerrg Thanks for your feedbacks.
The parentheses in Equation 9 in the paper should be absolute value.

The special treatment of the start and end intervals is mainly to prevent the fitted baseline from falling off in these two intervals.
Please refer to our MATLAB version for the implementation.

wi = [1:ceil(n*wep) floor(n-n*wep):n];

The Python version of airPLS was developed by Prof. Lombardo of the University of Palermo in 2014, and pull requests are welcomed if you are interested in improving the start and end interval processing.

Thank you!