code: def test_weightstats_2(self):
      x1, x2 = self.x1, self.x2
      w1, w2 = self.w1, self.w2
  
      d1 = DescrStatsW(x1)
      d1w = DescrStatsW(x1, weights=w1)
      d2w = DescrStatsW(x2, weights=w2)
      x1r = d1w.asrepeats()
      x2r = d2w.asrepeats()
      #        print 'random weights'
      #        print ttest_ind(x1, x2, weights=(w1, w2))
      #        print stats.ttest_ind(x1r, x2r)
      assert_almost_equal(
          ttest_ind(x1, x2, weights=(w1, w2))[:2],
          stats.ttest_ind(x1r, x2r),
          14,
      )
      # not the same as new version with random weights/replication
      #        assert x1r.shape[0] == d1w.sum_weights
      #        assert x2r.shape[0] == d2w.sum_weights
  
      assert_almost_equal(x2r.mean(0), d2w.mean, 14)
      assert_almost_equal(x2r.var(), d2w.var, 14)
      assert_almost_equal(x2r.std(), d2w.std, 14)
      # note: the following is for 1d
      assert_almost_equal(np.cov(x2r, bias=1), d2w.cov, 14)
      # assert_almost_equal(np.corrcoef(np.x2r), d2w.corrcoef, 19)
      # TODO: exception in corrcoef (scalar case)
  
      # one-sample tests
      #        print d1.ttest_mean(3)
      #        print stats.ttest_1samp(x1, 3)
      #        print d1w.ttest_mean(3)
      #        print stats.ttest_1samp(x1r, 3)
      assert_almost_equal(
          d1.ttest_mean(3)[:2], stats.ttest_1samp(x1, 3), 11
      )
      assert_almost_equal(
          d1w.ttest_mean(3)[:2], stats.ttest_1samp(x1r, 3), 11
      )
  
imports: import numpy
  from scipy import stats
  import pandas
  from numpy.testing import assert_, assert_almost_equal, assert_allclose
  from statsmodels.stats.weightstats import DescrStatsW, CompareMeans, ttest_ind, ztest, zconfint
  from statsmodels.tools.testing import Holder
label_desc: Use image node_id 3 for calling the TestWeightstats obj's underlying member method code with example usage: obj.test_weightstats_2() without return types