code: def estimate_trend_th(y, mode="default", ratio=0.01):
      """
      Estimate the min and max threshold based on y.
  
      :param y: actual values
      :param mode: types of ways to find threshold
          "default" : fit data to a uniform distribution (the percentile way)
          "gaussian": fit data to a gaussian distribution
      :param ratio: the ratio of anomaly to consider as anomaly.
      :return: tuple, the threshold (min, max)
      """
      if mode == "default":
          max_threshold = np.percentile(y, (1 - ratio) * 100)
          min_threshold = np.percentile(y, ratio * 100)
          return (min_threshold, max_threshold)
      elif mode == "gaussian":
          from scipy.stats import norm
  
          mu, sigma = norm.fit(y)
          max_t = norm.ppf(1 - ratio)
          min_t = norm.ppf(ratio)
          return (min_t * sigma + mu, max_t * sigma + mu)
      else:
          invalidInputError(False, f"Does not support ${mode}")
  
imports: import math
  import numpy
  from bigdl.chronos.detector.anomaly.abstract import AnomalyDetector
  from bigdl.nano.utils.common import invalidInputError
  from abc import ABC, abstractmethod
label_desc: Use image node_id 2 for calling a global function with example usage: estimate_trend_th(y, mode, ratio) and returns: min_threshold,  max_threshold, unknown,  unknown