@classmethod<EOL><INDENT>def random(cls, length, bit_prob=<NUM_LIT>):<DEDENT>
assert isinstance(length, int) and length >= <NUM_LIT:0><EOL>assert isinstance(bit_prob, (int, float)) and <NUM_LIT:0> <= bit_prob <= <NUM_LIT:1><EOL>bits = numpy.random.choice(<EOL>[False, True],<EOL>size=(length,),<EOL>p=[<NUM_LIT:1>-bit_prob, bit_prob]<EOL>)<EOL>bits.flags.writeable = False<EOL>return cls(bits)<EOL>
Create a bit string of the given length, with the probability of
        each bit being set equal to bit_prob, which defaults to .5.

        Usage:
            # Create a random BitString of length 10 with mostly zeros.
            bits = BitString.random(10, bit_prob=.1)

        Arguments:
            length: An int, indicating the desired length of the result.
            bit_prob: A float in the range [0, 1]. This is the probability
                of any given bit in the result having a value of 1; default
                is .5, giving 0 and 1 equal probabilities of appearance for
                each bit's value.
        Return:
            A randomly generated BitString instance of the requested
            length.