I am trying to use anomaly detection to find the anomalies in my time series, and if I find it, I will replace it with my past values. I'm trying to do this because I want to create an upper and lower bound to replace those anomalies and by using the past values will help me to create this bound. Is there any guidance or example, where I can learn to do this? Thanks!
A rudimental mechanical approach would be to track moving average & its moving standard deviation for a predefined time window of your dataset. Any handful of points that temporarily breach over or under your 3 standard deviation value are outliers (assuming no process shift) & you could replace these by the moving average.