code: def check_pmf_cdf(distfn, arg, distname):
      if hasattr(distfn, "xk"):
          index = distfn.xk
      else:
          startind = int(distfn.ppf(0.01, *arg) - 1)
          index = list(range(startind, startind + 10))
      cdfs = distfn.cdf(index, *arg)
      pmfs_cum = distfn.pmf(index, *arg).cumsum()
  
      atol, rtol = 1e-10, 1e-10
      if distname == "skellam":  # ncx2 accuracy
          atol, rtol = 1e-5, 1e-5
      npt.assert_allclose(
          cdfs - cdfs[0], pmfs_cum - pmfs_cum[0], atol=atol, rtol=rtol
      )
  
      # also check that pmf at non-integral k is zero
      k = np.asarray(index)
      k_shifted = k[:-1] + np.diff(k) / 2
      npt.assert_equal(distfn.pmf(k_shifted, *arg), 0)
  
      # better check frozen distributions, and also when loc != 0
      loc = 0.5
      dist = distfn(loc=loc, *arg)
      npt.assert_allclose(
          dist.pmf(k[1:] + loc), np.diff(dist.cdf(k + loc))
      )
      npt.assert_equal(dist.pmf(k_shifted + loc), 0)
  
imports: import numpy.testing
  from numpy.testing import assert_allclose
  import numpy
  import pytest
  from scipy import stats
  from .common_tests import check_normalization, check_moment, check_mean_expect, check_var_expect, check_skew_expect, check_kurt_expect, check_entropy, check_private_entropy, check_edge_support, check_named_args, check_random_state_property, check_pickling, check_rvs_broadcast, check_freezing
  from scipy.stats._distr_params import distdiscrete, invdistdiscrete
  from scipy.stats._distn_infrastructure import rv_discrete_frozen
label_desc: Use image node_id 8 for calling a global function with example usage: check_pmf_cdf(distfn, arg, distname) without return types