class_docstr: In this algorithm, a sign test is performed by comparing data points to the baseline.
  The baseline can be adjusted with an offset and a percent gain. How it works:
  The data is compared within a fixed window and if the results differ significantly from random
  then all points in that window are considered to be an anomaly.
  
  A confidence is used for the statistical null test, 0.01 is the default p_value
  
  The entire time series is scanned with a sliding window and all points are scored.
  
  Either upper or lower threshold can be requested, but not both.
  The lower threshold should be negative if the intent is to measure a drop below baseline.
  For example, a lower threshold of -20 will detect a 20 percent decrease when compared against baseline.
  
  This algorithm assumes that time_series and baseline_time_series are perfectly aligned, meaning that:
   a) every timestamp that exists in time_series also exists in baseline_time_series
   b) lengths of both time series are same
   c) the test window must not be larger than the time series
docstr: :param time_series: current time series
  :param baseline_time_series: baseline time series
  :param percent_threshold_upper: If time_series is larger than baseline_time_series by this percent, then its
  a candidate for an anomaly
  :param percent_threshold_lower: If time_series is smaller than baseline_time_series by this percent, then its
  a candidate for an anomaly. Percent_threshold_lower should be a negative number to work as intended.
  :param offset: baseline will be adjusted by this amount prior to computing percentage
                           TimeSeries > offset +    (1 + percent_threshold_upper/100) * Baseline
                           or for lower value
                           TimeSeries < offset +    (1 + percent_threshold_lower/100) * Baseline
  :param scan_window: number of data points to evaluate for anomalies default of 24 = 5 minute period for 2 hours
  :param confidence: Confidence to use for determining anomaly, default is 0.01
  :return:
docstr_tok: [":","param","time_series",":","current","time","series",":","param","baseline_time_series",":","baseline","time","series",":","param","percent_threshold_upper",":","If","time_series","is","larger","than","baseline_time_series","by","this","percent",",","then","its","a","candidate","for","an","anomaly",":","param","percent_threshold_lower",":","If","time_series","is","smaller","than","baseline_time_series","by","this","percent",",","then","its","a","candidate","for","an","anomaly",".","Percent_threshold_lower","should","be","a","negative","number","to","work","as","intended",".",":","param","offset",":","baseline","will","be","adjusted","by","this","amount","prior","to","computing","percentage","TimeSeries",">","offset","+","(","1","+","percent_threshold_upper\/100",")","*","Baseline","or","for","lower","value","TimeSeries","<","offset","+","(","1","+","percent_threshold_lower\/100",")","*","Baseline",":","param","scan_window",":","number","of","data","points","to","evaluate","for","anomalies","default","of","24","=","5","minute","period","for","2","hours",":","param","confidence",":","Confidence","to","use","for","determining","anomaly",",","default","is","0.01",":","return",":"]
code: def __init__(
      self,
      time_series,
      baseline_time_series,
      percent_threshold_upper=None,
      percent_threshold_lower=None,
      offset=0.0,
      scan_window=None,
      confidence=0.01,
  ):
      """
      :param time_series: current time series
      :param baseline_time_series: baseline time series
      :param percent_threshold_upper: If time_series is larger than baseline_time_series by this percent, then its
      a candidate for an anomaly
      :param percent_threshold_lower: If time_series is smaller than baseline_time_series by this percent, then its
      a candidate for an anomaly. Percent_threshold_lower should be a negative number to work as intended.
      :param offset: baseline will be adjusted by this amount prior to computing percentage
                               TimeSeries > offset +    (1 + percent_threshold_upper/100) * Baseline
                               or for lower value
                               TimeSeries < offset +    (1 + percent_threshold_lower/100) * Baseline
      :param scan_window: number of data points to evaluate for anomalies default of 24 = 5 minute period for 2 hours
      :param confidence: Confidence to use for determining anomaly, default is 0.01
      :return:
      """
      super(SignTest, self).__init__(
          self.__class__.__name__, time_series, baseline_time_series
      )
  
      if (
          percent_threshold_upper is None
          and percent_threshold_lower is None
      ):
          raise exceptions.RequiredParametersNotPassed(
              "luminol.algorithms.anomaly_detector_algorithms.sign_test: \
                      Either percent_threshold_upper or percent_threshold_lower is needed"
          )
  
      if (
          percent_threshold_upper is not None
          and percent_threshold_lower is not None
      ):
          raise exceptions.RequiredParametersNotPassed(
              "luminol.algorithms.anomaly_detector_algorithms.sign_test: \
                      Cannot specify both percent_threshold_upper and percent_threshold_lower"
          )
  
      if not scan_window:
          raise exceptions.RequiredParametersNotPassed(
              "luminol.algorithms.anomaly_detector_algorithms.sign_test: \
                      scan window size needs to be specified"
          )
  
      # make assignements
      self.scan_window = scan_window
      self.confidence = confidence
      self.offset = offset
  
      self.percent_threshold = (
          percent_threshold_upper
          if percent_threshold_upper is not None
          else percent_threshold_lower
      )
  
      # scale will transform the time series and baseline
      # if we are detecting lower threshold we mirror the data
      self.scale = 1 if percent_threshold_upper is not None else -1
  
file_path: luminol/src/luminol/algorithms/anomaly_detector_algorithms/sign_test.py
imports: import numpy
  from luminol import exceptions
  from luminol.algorithms.anomaly_detector_algorithms import AnomalyDetectorAlgorithm
  from luminol.utils import qbinom, pbinom
  from luminol.modules.time_series import TimeSeries
label_desc: Use image node_id 1 to create a new SignTest object from inherited base classes: AnomalyDetectorAlgorithm with example: obj = SignTest(time_series, baseline_time_series, percent_threshold_upper, percent_threshold_lower, offset, scan_window, confidence)