code: def madmedianrule(a):
      
      from scipy.stats import chi2
      a = np.asarray(a)
      k = np.sqrt(chi2.ppf(0.975, 1))
      return (np.fabs(a - np.median(a)) / mad(a)) > k
docs: Outlier detection based on the MAD-median rule.
  
      Parameters
      ----------
      a : array-like
          Input array.
  
      Returns
      -------
      outliers: boolean (same shape as a)
          Boolean array indicating whether each sample is an outlier (True) or
          not (False).
  
      References
      ----------
      .. [1] Hall, P., Welsh, A.H., 1985. Limit theorems for the median
         deviation. Ann. Inst. Stat. Math. 37, 27–36.
         https://doi.org/10.1007/BF02481078
  
      Examples
      --------
      >>> from pingouin import madmedianrule
      >>> a = [-1.09, 1., 0.28, -1.51, -0.58, 6.61, -2.43, -0.43]
      >>> madmedianrule(a)
      array([False, False, False, False, False,  True, False, False])