mikeblazanin / gcplyr

gcplyr is an R package that facilitates wrangling and analysis of microbial growth curve data
https://mikeblazanin.github.io/gcplyr/
Other
30 stars 2 forks source link

Add regularization smoother #209

Open mikeblazanin opened 7 months ago

mikeblazanin commented 7 months ago

Also called a whittaker smoother, implemented in pracma::whittaker

See: Eilers, Paul HC. "A perfect smoother." Analytical chemistry 75.14 (2003): 3631-3636. Stickel, Jonathan J. "Data smoothing and numerical differentiation by a regularization method." Computers & chemical engineering 34.4 (2010): 467-475.

Rudimentary implementation of Eilers' algorithm directly (basically stolen from pracma::whittaker)

mywhittaker <- function (y, lambda = 1600, d = 2) {
  m <- length(y)
  E <- diag(nrow = m, ncol = m)
  D <- diff(E, lag = 1, differences = d)
  B <- E + (lambda * t(D) %*% D)
  z <- solve(B, y)
  return(z)
}

This is a spinoff from #89

mikeblazanin commented 6 months ago

See explanation at: https://towardsdatascience.com/the-perfect-way-to-smooth-your-noisy-data-4f3fe6b44440