Tests that repeatedly calling ``rand()`` should result in a sample that is approximately uniformly distributed.
(seed: int)
| 43 | |
| 44 | @mark.parametrize("seed", [2, 10, 42]) |
| 45 | def test_rand(seed: int): |
| 46 | """ |
| 47 | Tests that repeatedly calling ``rand()`` should result in a sample that is |
| 48 | approximately uniformly distributed. |
| 49 | """ |
| 50 | rng = RandomNumberGenerator(seed) |
| 51 | sample = np.array([rng.rand() for _ in range(10_000)]) |
| 52 | |
| 53 | # The sample should be almost uniform, so mean 1/ 2 and variance 1 / 12, |
| 54 | # and every realisation needs to be in [0, 1]. |
| 55 | assert_allclose(sample.mean(), 1 / 2, atol=1e-3) |
| 56 | assert_allclose(sample.var(), 1 / 12, atol=1e-3) |
| 57 | assert_(0 <= sample.min() < sample.max() <= 1) |
| 58 | |
| 59 | |
| 60 | @mark.parametrize("state", [[1, 2, 3, 4], [10, 14, 274, 83]]) |
nothing calls this directly
no test coverage detected