'Triangular distribution.
Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between.
http://en.wikipedia.org/wiki/Triangular_distribution'

def triangular(self, low=0.0, high=1.0, mode=None):

    u = self.random()
    try:
        c = (0.5 if (mode is None) else ((mode - low) / (high - low)))
    except ZeroDivisionError:
        return low
    if (u > c):
        u = (1.0 - u)
        c = (1.0 - c)
        (low, high) = (high, low)
    return (low + ((high - low) * ((u * c) ** 0.5)))
