def random(self): """Get a random point in binary space. Use the constraint to generate a random point in the space if possible, otherwise use a random byte string. """ return TernaryString.random(self.dim)
def test_random(self): total = np.zeros(100) for i in xrange(10000): total += TernaryString.random(100).toArray() / 10000.0 print "Total max: ", self.assertTrue(np.abs(total - .5).max() < .025)