I am new to statistics. I have a problem at hand for which I need to code all the 4 rules of Western Electric rules for Quality control. I have been able to code the first one and second with the help of my peer, could anyone help me out in writing down rule number 4 - "NINE consecutive points fall on the same side of the centerline"
I have plotted rule 1 by getting the data below and above the threshold and then ran the matplotlib plot in single cell.
I am not able to get the data for rule number 4.
Really late followup, but you could do something like "if minimum of previous 9 points and maximum of previous 9 points are both same side (> or <) mean, failure."
This shows the rolling min, rolling max should work similarly https://stackoverflow.com/a/33920859/18474867
Generate a "rolling min" and "rolling max" column for the last 9 rows, if anywhere they're both + or both -, flag it as a failure.