def test_sample_distribution(self): n_samples = 1000 np.random.seed(805) bounds = np.random.rand(2) + np.array([0, 1]) u = Uniform(*bounds) samples = u.sample(n_samples) p_val = kstest(samples, 'uniform', (bounds[0], np.diff(bounds)))[1] self.assertTrue(p_val > 0.05)
def test_sample_shape(self): n_samples = 7 bounds = np.random.rand(2) + np.array([0, 1]) u = Uniform(*bounds) samples = u.sample(n_samples) self.assertEqual(samples.shape, np.array(n_samples)) self.assertTrue(np.all(samples > bounds[0])) self.assertTrue(np.all(samples < bounds[1]))