def testDistributionOfNormal(self, dtype): """Use Anderson-Darling test to test distribution appears normal.""" n = 1000 gen = random.Generator(seed=1234) x = gen.normal(shape=[n], dtype=dtype).numpy() # The constant 2.492 is the 5% critical value for the Anderson-Darling # test where the mean and variance are known. This test is probabilistic # so to avoid flakiness the seed is fixed. self.assertLess( random_test_util.anderson_darling(x.astype(float)), 2.492)
def testDistributionOfNormal(self): """Use Anderson-Darling test to test distribution appears normal.""" with ops.device(xla_device_name()): n = 1000 for dtype in {dtypes.float32}: gen = random.Generator(seed=1234, algorithm=random.RNG_ALG_THREEFRY) x = gen.normal(shape=[n], dtype=dtype).numpy() # The constant 2.492 is the 5% critical value for the Anderson-Darling # test where the mean and variance are known. This test is probabilistic # so to avoid flakiness the seed is fixed. self.assertLess( random_test_util.anderson_darling(x.astype(float)), 2.492)
def testDistributionOfNormal(self): """Use Anderson-Darling test to test distribution appears normal.""" with ops.device(xla_device_name()): n = 1000 for dtype in self._floats: gen = random.Generator(seed=1234, algorithm=random.RNG_ALG_THREEFRY) x = gen.normal(shape=[n], dtype=dtype).numpy() # The constant 2.492 is the 5% critical value for the Anderson-Darling # test where the mean and variance are known. This test is probabilistic # so to avoid flakiness the seed is fixed. self.assertLess( random_test_util.anderson_darling(x.astype(float)), 2.492)
def testDistributionOfStatelessRandomNormal(self): """Use Anderson-Darling test to test distribution appears normal.""" with self.session() as sess, self.test_scope(): for dtype in self._random_types(): seed_t = array_ops.placeholder(dtypes.int32, shape=[2]) n = 1000 x = stateless.stateless_random_normal( shape=[n], seed=seed_t, dtype=dtype) y = sess.run(x, {seed_t: [25252, 314159]}) # The constant 2.492 is the 5% critical value for the Anderson-Darling # test where the mean and variance are known. This test is probabilistic # so to avoid flakiness the seed is fixed. self.assertLess( random_test_util.anderson_darling(y.astype(float)), 2.492)
def testDistributionOfStatelessRandomNormal(self): """Use Anderson-Darling test to test distribution appears normal.""" with self.cached_session() as sess, self.test_scope(): for dtype in self._random_types(): seed_t = array_ops.placeholder(dtypes.int32, shape=[2]) n = 1000 x = stateless.stateless_random_normal( shape=[n], seed=seed_t, dtype=dtype) y = sess.run(x, {seed_t: [25252, 314159]}) # The constant 2.492 is the 5% critical value for the Anderson-Darling # test where the mean and variance are known. This test is probabilistic # so to avoid flakiness the seed is fixed. self.assertLess( random_test_util.anderson_darling(y.astype(float)), 2.492)