code: private void calculateContextualAnomalyScores(Map<Long, Double> predictionDatapoints,
                                                    Map<Long, Double> completeDatapoints,
                                                    Long[] timestamps,
                                                    int currentIndex, long detectionIntervalInSeconds) {
          for (int i = currentIndex; i < timestamps.length; i++) {
              long timestampAtCurrentIndex = timestamps[i];
              long projectedIntervalStartTime = timestampAtCurrentIndex - detectionIntervalInSeconds;
  
              Metric intervalMetric = createIntervalMetric(i, completeDatapoints, timestamps,
                                          projectedIntervalStartTime);
              List<Metric> intervalRawDataMetrics = new ArrayList<>();
              intervalRawDataMetrics.add(intervalMetric);
  
              //Apply the anomaly detection transform to each interval separately
              Metric intervalAnomaliesMetric = transform(null, intervalRawDataMetrics).get(0);
              Map<Long, Double> intervalAnomaliesMetricData = intervalAnomaliesMetric.getDatapoints();
              predictionDatapoints.put(timestamps[i],
                      intervalAnomaliesMetricData.get(timestamps[i]));
          }
      }
docs: Creates an interval for each data point (after currentIndex) in the metric
  and calculates the anomaly score for that data point using only other data
  points in that same interval, i.e. "a moving contextual anomaly score"
  
  @param predictionDatapoints data points to fill with contextual anomaly scores
  @param completeDatapoints original metric data points
  @param timestamps sorted timestamps of the original metric
  @param currentIndex index at which to start contextual anomaly detection
  @param detectionIntervalInSeconds anomaly detection interval