class_docstr: A detector based on normal distribution.
  A normal distribution if fitted to data and then any points outside
  the range
      ``(mu - sig * z, mu + sig * z)``
  is considered an outliar, where
  
  - mu : mean of the data
  - sig : standard deviation of the data
  - z : the coefficient used for defining the confidence interval width.
      We assume ``z = stats.norm.ppf(p)`` for some ``p`` in ``(0.5, 1)`` range.
  
  This detector uses data to find the optimal ``p`` during fit.
  The optimizer implementation is inherited from
      `~greykite.detection.detector.detector.Detector`
class_docstr_tok: ["A","detector","based","on","normal","distribution",".","A","normal","distribution","if","fitted","to","data","and","then","any","points","outside","the","range","``","(","mu","-","sig","*","z",",","mu","+","sig","*","z",")","``","is","considered","an","outliar",",","where","-","mu",":","mean","of","the","data","-","sig",":","standard","deviation","of","the","data","-","z",":","the","coefficient","used","for","defining","the","confidence","interval","width",".","We","assume","``","z","=","stats.norm.ppf","(","p",")","``","for","some","``","p","``","in","``","(","0.5",",","1",")","``","range",".","This","detector","uses","data","to","find","the","optimal","``","p","``","during","fit",".","The","optimizer","implementation","is","inherited","from","`","~greykite.detection.detector.detector.Detector","`"]
code: def calc_with_param(self, param, data):
      df = data.df
      assert self.value_col in df.columns
      err = stats.norm.ppf(param["prob_thresh"]) * param["sig"]
      param["upper"] = param["mu"] + err
      param["lower"] = param["mu"] - err
      param["err"] = err
  
      df[PREDICTED_ANOMALY_COL] = (
          df[self.value_col] < param["lower"]
      ) | (df[self.value_col] > param["upper"])
  
      data.y_pred = df[PREDICTED_ANOMALY_COL]
      return CalcResult(data=data)
  
imports: import numpy
  import pandas
  import pytest
  from scipy import stats
  from greykite.common.constants import PREDICTED_ANOMALY_COL
  from greykite.common.viz.timeseries_annotate import plot_lines_markers
  from greykite.detection.common.ad_evaluation import f1_score
  from greykite.detection.detector.data import DetectorData
  from greykite.detection.detector.detector import Detector
  from greykite.detection.detector.detector import build_anomaly_percent_reward
  from greykite.detection.detector.optimizer import CalcResult
  from greykite.detection.detector.reward import Reward
label_desc: Use image node_id 3 for calling the NormalDetector obj's underlying member method code with example usage: obj.calc_with_param(param, data) and returns: CalcResult