code: def test_chi2_moments(self):
      # construct the expansion for \chi^2
      N, df = 6, 15
      cum = [_chi2_cumulant(n + 1, df) for n in range(N)]
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", RuntimeWarning)
          ne = ExpandedNormal(cum, name="edgw_chi2")
  
      # compare the moments
      assert_allclose(
          [_chi2_moment(n, df) for n in range(N)],
          [ne.moment(n) for n in range(N)],
      )
  
      # compare the pdf [fragile!]
      # this one is actually not a very good test: there is, strictly
      # speaking, no guarantee that the pdfs match point-by-point
      # m, s = df, np.sqrt(df)
      # x = np.linspace(m - s, m + s, 10)
      # assert_allclose(ne.pdf(x), stats.chi2.pdf(x, df),
      #        atol=1e-4, rtol=1e-5)
  
      # pdf-cdf roundtrip
      check_pdf(ne, arg=(), msg="")
  
      # cdf-ppf roundtrip
      check_cdf_ppf(ne, arg=(), msg="")
  
      # cdf + sf == 1
      check_cdf_sf(ne, arg=(), msg="")
  
      # generate rvs & run a KS test
      np.random.seed(765456)
      rvs = ne.rvs(size=500)
      check_distribution_rvs(ne, args=(), alpha=0.01, rvs=rvs)
  
imports: import warnings
  import numpy
  from numpy.testing import assert_equal, assert_raises, assert_allclose
  import numpy.testing
  from scipy.special import gamma, factorial, factorial2
  import scipy.stats
  from statsmodels.distributions.edgeworth import _faa_di_bruno_partitions, cumulant_from_moments, ExpandedNormal
label_desc: Use image node_id 4 for calling the TestExpandedNormal obj's underlying member method code with example usage: obj.test_chi2_moments() without return types