code: def stetson_mean(x, param=stestson_param):
      weight = stestson_param["weight"]
      alpha = stestson_param["alpha"]
      beta = stestson_param["beta"]
      tol = stestson_param["tol"]
      nmax = stestson_param["nmax"]
  
      mu = np.median(x)
      for i in range(nmax):
          resid = x - mu
          resid_err = np.abs(resid) * np.sqrt(weight)
          weight1 = weight / (1.0 + (resid_err / alpha) ** beta)
          weight1 /= weight1.mean()
          diff = np.mean(x * weight1) - mu
          mu += diff
          if np.abs(diff) < tol * np.abs(mu) or np.abs(diff) < tol:
              break
  
      return mu
  
imports: import pandas
  import numpy
  from statsmodels.tsa.stattools import acf, adfuller, pacf
  import itertools
  from statsmodels.tsa.ar_model import AR
  from scipy.signal import cwt, find_peaks_cwt, ricker, welch
  from scipy.stats import linregress
  import scipy.stats
  from scipy.stats import kurtosis
  from scipy.stats import skew
  import numpy
  from scipy import signal, integrate
  from scipy.interpolate import interp1d
  import math
  from statsmodels.tools.sm_exceptions import MissingDataError
  from numpy.linalg import LinAlgError
label_desc: Use image node_id 14 for calling a global function with example usage: stetson_mean(x, param) and returns: mu