'Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.'

def betavariate(self, alpha, beta):

    y = self.gammavariate(alpha, 1.0)
    if (y == 0):
        return 0.0
    else:
        return (y / (y + self.gammavariate(beta, 1.0)))
