def test_shuffle_vs_alpha(self):
        print("Checking that bootstrap conf intervals equal analytical ones "
              "for conf_lev = %.2f, conf_samples = %d" % (self.conf_lev,
                                                          self.conf_samples))
        for measure in ['reg', 'par_corr', 'cmi_gauss']:

            tmp = te._get_estimate(array=self.array,
                                   measure=measure, xyz=self.xyz,
                                   confidence='analytic',
                                   conf_samples=self.conf_samples,
                                   conf_lev=self.conf_lev,
                                   measure_params=self.measure_params,
                                   verbosity=0)
            expected = tmp['conf_lower'], tmp['conf_upper']

            tmp = te._get_estimate(array=self.array,
                                   measure=measure, xyz=self.xyz,
                                   confidence='bootstrap',
                                   conf_samples=self.conf_samples,
                                   conf_lev=self.conf_lev,
                                   measure_params=self.measure_params,
                                   verbosity=0)
            res = tmp['conf_lower'], tmp['conf_upper']

            print("bootstrap interval for %s = (%.3f, %.3f)  -- "
                  "analytic interval = (%.3f, %.3f)" % (
                      measure, res[0], res[1], expected[0], expected[1]))
            numpy.testing.assert_allclose(res, expected, rtol=self.rtol)
    def test_shuffle_vs_alpha(self):
        print("Checking that bootstrap conf intervals equal analytical ones "
              "for conf_lev = %.2f, conf_samples = %d" %
              (self.conf_lev, self.conf_samples))
        for measure in ['reg', 'par_corr', 'cmi_gauss']:

            tmp = te._get_estimate(array=self.array,
                                   measure=measure,
                                   xyz=self.xyz,
                                   confidence='analytic',
                                   conf_samples=self.conf_samples,
                                   conf_lev=self.conf_lev,
                                   measure_params=self.measure_params,
                                   verbosity=0)
            expected = tmp['conf_lower'], tmp['conf_upper']

            tmp = te._get_estimate(array=self.array,
                                   measure=measure,
                                   xyz=self.xyz,
                                   confidence='bootstrap',
                                   conf_samples=self.conf_samples,
                                   conf_lev=self.conf_lev,
                                   measure_params=self.measure_params,
                                   verbosity=0)
            res = tmp['conf_lower'], tmp['conf_upper']

            print("bootstrap interval for %s = (%.3f, %.3f)  -- "
                  "analytic interval = (%.3f, %.3f)" %
                  (measure, res[0], res[1], expected[0], expected[1]))
            numpy.testing.assert_allclose(res, expected, rtol=self.rtol)
 def test_shuffle_vs_alpha(self):
     print("Checking that shuffle sig_thres equals analytical thres "
           "for sig_lev = %.2f, sig_samples = %d" % (self.sig_lev,
                                                     self.sig_samples))
     numpy.random.seed(42)
     # array = numpy.random.randn(2, self.T)
     links_coeffs = {0: [],
                     1: [((0, 0), .06)], }
     data, links = pp.var_process(links_coeffs, T=self.T,
                                  use='inno_cov', verbosity=verbosity)
     array = data.T
     xyz = numpy.array([0, 1])
     for measure in ['par_corr', 'reg']:
         expected = te._get_estimate(array=array, measure=measure, xyz=xyz,
                                     significance='analytic',
                                     sig_samples=self.sig_samples,
                                     sig_lev=self.sig_lev,
                                     measure_params=self.measure_params,
                                     verbosity=0)['sig_thres']
         res = te._get_estimate(array=array, measure=measure, xyz=xyz,
                                significance='full_shuffle',
                                sig_samples=self.sig_samples,
                                sig_lev=self.sig_lev,
                                measure_params=self.measure_params,
                                verbosity=0)['sig_thres']
         print("shuffle %.2f sig thres for %s = %.4f (analytic = %.4f)"
               % (self.sig_lev, measure, res, expected))
         numpy.testing.assert_allclose(res, expected, rtol=self.rtol)
 def test_shuffle_vs_alpha(self):
     print("Checking that shuffle sig_thres equals analytical thres "
           "for sig_lev = %.2f, sig_samples = %d" %
           (self.sig_lev, self.sig_samples))
     numpy.random.seed(42)
     # array = numpy.random.randn(2, self.T)
     links_coeffs = {
         0: [],
         1: [((0, 0), .06)],
     }
     data, links = pp.var_process(links_coeffs,
                                  T=self.T,
                                  use='inno_cov',
                                  verbosity=verbosity)
     array = data.T
     xyz = numpy.array([0, 1])
     for measure in ['par_corr', 'reg']:
         expected = te._get_estimate(array=array,
                                     measure=measure,
                                     xyz=xyz,
                                     significance='analytic',
                                     sig_samples=self.sig_samples,
                                     sig_lev=self.sig_lev,
                                     measure_params=self.measure_params,
                                     verbosity=0)['sig_thres']
         res = te._get_estimate(array=array,
                                measure=measure,
                                xyz=xyz,
                                significance='full_shuffle',
                                sig_samples=self.sig_samples,
                                sig_lev=self.sig_lev,
                                measure_params=self.measure_params,
                                verbosity=0)['sig_thres']
         print("shuffle %.2f sig thres for %s = %.4f (analytic = %.4f)" %
               (self.sig_lev, measure, res, expected))
         numpy.testing.assert_allclose(res, expected, rtol=self.rtol)