code: def _func(a, p, r, v):
      """
      calculates f-hat for the coefficients in a, probability p,
      sample mean difference r, and degrees of freedom v.
      """
      # eq. 2.3
      f = (
          a[0] * math.log(r - 1.0)
          + a[1] * math.log(r - 1.0) ** 2
          + a[2] * math.log(r - 1.0) ** 3
          + a[3] * math.log(r - 1.0) ** 4
      )
  
      # eq. 2.7 and 2.8 corrections
      if r == 3:
          f += -0.002 / (1.0 + 12.0 * _phi(p) ** 2)
  
          if v <= 4.364:
              v = v if not np.isinf(v) else 1e38
              f += 1.0 / 517.0 - 1.0 / (312.0 * v)
          else:
              v = v if not np.isinf(v) else 1e38
              f += 1.0 / (191.0 * v)
  
      return -f
  
file_path: statsmodels/statsmodels/stats/libqsturng/qsturng_.py
imports: from statsmodels.compat.python import lrange
  import math
  import scipy.stats
  import numpy
  from scipy.optimize import fminbound
label_desc: Use image node_id 4 for calling a global function with example usage: _func(a, p, r, v) and returns: unknown