def testBiasedRandomWalk(self, timescale): stdev = 1. variation = distributions.BiasedRandomWalk(stdev=stdev, timescale=timescale) sequence = [variation(random_state=self._variation_random_state) for _ in range(int(max(timescale, 1)*NUM_ITERATIONS*1000))] self.assertAlmostEqual(np.mean(sequence), 0., delta=0.01) self.assertAlmostEqual(np.std(sequence), stdev, delta=0.01)
def testBiasedRandomWalkExceptions(self, arg_name, template): bad_value = -1. with self.assertRaisesWithLiteralMatch(ValueError, template.format(bad_value)): _ = distributions.BiasedRandomWalk(**{arg_name: bad_value})