Пример #1
0
    def test_assignment_example(self):
        modulus = 2147483642
        multiplier = 450

        lcg = LCG(LCGParams(modulus, multiplier))
        generator = lcg.generator()

        for i in range(0, 100):
            entry = next(generator)
            self.assertTrue(0 <= entry < modulus)
Пример #2
0
    def test_slides_example(self):

        lcg = LCG(LCGParams(10, 7, 7))
        generator = lcg.generator(7)

        iterations = 6
        sequence = []

        i = 0
        while i < iterations:
            sequence.append(next(generator))
            i += 1

        self.assertEqual(sequence[0], 7)
        self.assertEqual(sequence[1], 6)
        self.assertEqual(sequence[2], 9)
        self.assertEqual(sequence[3], 0)
        self.assertEqual(sequence[4], 7)
        self.assertEqual(sequence[5], 6)