I think you could write your own function like this
from random import random
from math import sqrt
def triangular(a, c, b):
c = float(c)
t = (c-a)/(b-a)
y = sqrt(random())
d = a if random() < t else b
return d + (c-d) * y
if __name__ == "__main__":
for i in range(100):
print(triangular(1, 3, 4)) Explanation: I start from the density function in the wikipedia page http://en.wikipedia.org/wiki/Triangular_distribution . Obviously, if a random variable Z has this distribution, the probability that it's between a and c is t=(c-a)/(b-a). So I first choose if the variable must be between a and c or between c and b by comparing a uniformly random number in [0,1] to this value. Then I choose a first Y which is the square root of a uniformly random number between 0 and 1. Such a variable has a linear density function f(t) = 2 t in (0, 1]. This is easy to compute. Then I rescale this variable so that it falls between [a, c] or [c, b].
There is some work if you want to convince yourself that it works, but I'm rather good at math, so it should :)