The answer i give is probably partly help full.
What you can do is when you have a pre stored STD and a MEAN(N samples long). Than duringWhile running the real time proces update the savedstored MEAN (Array.
Create an array of you mean value) by adding. During the loop add every timecycle a sample to your array and remove the oldest one you. You create a kind of circular pattern. After N samples your MEAN is only the MEAN from your data.
Do the same with the STD.
Maybe you can create a different MEAN and STD from different types of data so the error is less worse
Good Luck