Notebook
This cell below breaks because numpy has been renamed as np -Blaine
An online simulation function might look something like this: ---------------------- (pseudocode) function online_simulator(signal, cd_algorithm, stopping rules): Iterate through the signal, passing data points to the algorithm. FOR EACH data point Calculate residuals Compare residuals with the stopping rule(s) IF the stopping rule is triggered RETURN (True, residuals, stopping_rule_triggered) At the end of the signal, IF the stopping rule is not triggered THEN return (False, residuals) I am not clear on 'Essentially the algorithm is just calculating residuals and updating them for each new value passed.' -- [Blaine]What about the change detection algorithm, what does that look like? Essentially the algorithm is just calculating residuals and updating them for each new value passed. ------------------------- (pseudocode) class cd_algorithm: Initialization initialize residuals METHOD step FOR EACH new_signal_value Update residuals Check if Stopping Rules have been triggered IF rules_triggered RETURN (True, residuals, signal_size, stopping_rule_triggered) ---- actually we'll make that step method into a generator, so we can yield values for each new value of the signal.
What is the type/object of the signal that is being iterated over? -- [Blaine]
(Note that the stopping rule was not triggered, because we haven't created a stopping rule yet.)
Now we have a residual `diff`, which is just the difference between the latest signal value and the mean. We also have a stopping rule triggered if `diff` is greater than a manually provided threshold value. While this worked for our basic signal, this change detector is very weak. In particular, the algorithm is very sensitive to the threshold value, which must be determined manually. * if the threshold is too small, the stopping rule will be triggered by insignificant changes in the signal, such as noise. * if the threshold is too large, it will fail to trigger on important but smaller changes. The next signal will illustrate these weaknesses.
The stopping rule was triggered by the noise in the signal, giving us a false positive.
With this new threshold our stopping rule is not sensitive enough, and returns a false negative (the stopping Rule was not triggered). Ideally, we want a change detector that is less sensitive to hyper-parameters, such that it can catch change of unknown magnitude in signals. [AmanAhuja: Actually, our next step is to use windows. So the next example should justify maintaining and comparing two separate statistics (instead of absolute values). We explain capturing a local sample and comparing it to the global population. Then we can reduce dependence on hyperpameters via CUSUM, etc. ]
Noise: Noise in the signal justifies using statistics instead of absolutes such as amplitude. We therefore have to maintain two "windows" of data, computing statistics for each, and then comparing them. One common approach is to have a streaming window of some fixed size that contains the n most recent data points, and comparing this to the "global" window consisting of all the data from time=0 to the most recent. Another reason for using streaming windows is a practical one -- in many streaming problems, it is impossible to store and work with the entire history of data points. Instead we keep just one or few limited sets of data. [Aman Ahuja: This discussion leads to --> streaming statistics such as Welford's Method. ]
Welford's Method to compute running mean and running variance/std Welford 1962, see also Knuth, AOCP Vol. 2 page 232 http://www.johndcook.com/standard_deviation.html
In this way we can collect decent statistics on a stream of data without having to store the entire history.
Note [Aman Ahuja] So far this demonstrates the need for windows, but still has a dependency on hyperparameters. - How would we know what to pick for the Z-score threshold? - We also now have a new hyper parameter, the window size. This discussion leads to the Page Hinkley Stopping Rule The likelihood ratio, or the ratio of the gaussian probability densities, can be used to detect the time at which the change occurred, if the magnitude of the jump (magnitude of the change in mean) is known a priori. Else the maximum likelihood estimate of the point (time) of change can be used, requiring some threshold value lambda for the size of the change in mean. This leads to the Page-Hinkley stopping rule (E.S. Page, 1954) and the cumulative sum algorithm (CUSUM) There is a recursive method to compute the stopping rule.
Criteria for designing detection algorithms (or analyzing their performance) - mean time b/w false alarms - prob of wrong detection [false positives] - mean delay to detection - prob of non-detection [false negatives] - accuracy of the estimates of the fault onset time and of magnitude of change Topics yet to cover: - likelihood ratio and cumalative sum tests. - the Page-Hinkley Stopping Rule - using local approaches and moving windows to reduce computation costs. - spectral properties of the incoming signal - CUSUM - peak detection vs. drift detection