def _compute_anom_data_using_window(self):
anom_scores = {}<EOL>values = self.time_series.values<EOL>stdev = numpy.std(values)<EOL>for i, (timestamp, value) in enumerate(self.time_series_items):<EOL><INDENT>if i < self.lag_window_size:<EOL><INDENT>anom_score = self._compute_anom_score(values[:i + <NUM_LIT:1>], value)<EOL><DEDENT>else:<EOL><INDENT>anom_score = self._compute_anom_score(values[i - self.lag_window_size: i + <NUM_LIT:1>], value)<EOL><DEDENT>if stdev:<EOL><INDENT>anom_scores[timestamp] = anom_score / stdev<EOL><DEDENT>else:<EOL><INDENT>anom_scores[timestamp] = anom_score<EOL><DEDENT><DEDENT>self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))<EOL>
Compute anomaly scores using a lagging window.