from random import random, uniform

def random_triangular(low, high, mode):
    while True:
        proposal = uniform(low, high)
if proposal < mode:
    acceptance_prob = (proposal - low) / (mode - low)
else:
    acceptance_prob = (high - proposal) / (high - mode)
if random() < acceptance_prob:
    break
return proposal
Python, SimPy: как сгенерировать значение из треугольного распределения вероятностей?