code: def polyF(dim, dfd=np.inf, dfn=1):
      r"""
      Return the polynomial part of the EC density when evaluating the polynomial
      on the sqrt(F) scale (or sqrt(chi^2)=chi scale).
  
      The polynomial is such that, if dfd=inf, the F EC density in is just::
  
          polyF(dim,dfn=dfn)(sqrt(dfn*x)) * exp(-dfn*x/2) * (2\pi)^{-(dim+1)/2}
      """
      n = float(dfn)
      m = float(dfd)
      D = float(dim)
      p = K(dim=D, dfd=m, dfn=n)
      c = p.c
      # Take care of the powers of n (i.e. we want polynomial K evaluated
      # at */n).
      for i in range(p.order + 1):
          c[i] /= np.power(n, p.order - i)
      # Now, turn it into a polynomial of x when evaluated at x**2
      C = np.zeros((2 * c.shape[0] - 1,))
      for i in range(c.shape[0]):
          C[2 * i] = c[i]
      # Multiply by the factor x^(dfn-dim) in front (see Theorem 4.6 of
      # Worsley (1994), cited above.
      if dim > dfn:  # divide by x^(dim-dfn)
          C = C[0 : (C.shape[0] - (dim - dfn))]
      else:  # multiply by x^(dim-dfn)
          C = np.hstack([C, np.zeros((dfn - dim,))])
      # Fix up constant in front
      if np.isfinite(m):
          C *= np.exp(
              gammaln((m + n - D) / 2.0) - gammaln(m / 2.0)
          ) * np.power(m, -(n - D) / 2.0)
      else:
          C *= np.power(2, -(n - D) / 2.0)
      C /= np.power(2, (dim - 2) / 2.0) * np.exp(gammaln(n / 2.0))
      C *= np.sqrt(2 * np.pi)
      return np.poly1d(C)
  
imports: import numpy
  import scipy.stats
  from scipy.special import gammaln, hermitenorm
  import pytest
  from numpy.testing import assert_almost_equal
  from ..None import rft
label_desc: Use image node_id 4 for calling a global function with example usage: polyF(dim, dfd, dfn) and returns: np