code: def test_grid():
      # test bivariate independent beta
      k1, k2 = 3, 5
      xg1 = np.arange(k1) / (k1 - 1)
      xg2 = np.arange(k2) / (k2 - 1)
  
      # histogram values for distribution
      distr1 = stats.beta(2, 5)
      distr2 = stats.beta(4, 3)
      cdf1 = distr1.cdf(xg1)
      cdf2 = distr2.cdf(xg2)
      prob1 = np.diff(cdf1, prepend=0)
      prob2 = np.diff(cdf2, prepend=0)
      cd2d = cdf1[:, None] * cdf2
      pd2d = prob1[:, None] * prob2
  
      probs = dt.cdf2prob_grid(cd2d)
      cdfs = dt.prob2cdf_grid(pd2d)
  
      assert_allclose(cdfs, cd2d, atol=1e-12)
      assert_allclose(probs, pd2d, atol=1e-12)
  
      # check random sample
      nobs = 1000
      np.random.seed(789123)
      rvs = np.column_stack(
          [distr1.rvs(size=nobs), distr2.rvs(size=nobs)]
      )
      hist = np.histogramdd(rvs, [xg1, xg2])
      assert_allclose(probs[1:, 1:], hist[0] / len(rvs), atol=0.02)
  
file_path: statsmodels/statsmodels/distributions/tests/test_tools.py
imports: import numpy
  from numpy.testing import assert_allclose, assert_equal
  from scipy import stats
  import statsmodels.distributions.tools
label_desc: Use image node_id 1 for calling a global function with example usage: test_grid() without return types