コード例 #1
0
 def testChi2Variance(self):
   with self.cached_session():
     df_v = np.array([1., 3, 5], np.float64)
     expected_variances = stats.chi2.var(df_v)
     chi2 = chi2_lib.Chi2(df=df_v)
     self.assertEqual(chi2.variance().get_shape(), (3,))
     self.assertAllClose(chi2.variance().eval(), expected_variances)
コード例 #2
0
 def testChi2Entropy(self):
   with self.cached_session():
     df_v = np.array([1., 3, 5], dtype=np.float64)
     expected_entropy = stats.chi2.entropy(df_v)
     chi2 = chi2_lib.Chi2(df=df_v)
     self.assertEqual(chi2.entropy().get_shape(), (3,))
     self.assertAllClose(chi2.entropy().eval(), expected_entropy)
コード例 #3
0
  def testChi2CDF(self):
    with self.cached_session():
      batch_size = 6
      df = constant_op.constant([2.0] * batch_size, dtype=np.float64)
      df_v = 2.0
      x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float64)

      chi2 = chi2_lib.Chi2(df=df)
      expected_cdf = stats.chi2.cdf(x, df_v)

      cdf = chi2.cdf(x)
      self.assertEqual(cdf.get_shape(), (6,))
      self.assertAllClose(cdf.eval(), expected_cdf)