[Tutor] What is random.triangular() used for

Richard D. Moores rdmoores at gmail.com
Sun Oct 24 22:17:51 CEST 2010

In looking through the doc on the random module I came across

random.triangular(low, high, mode)
Return a random floating point number N such that low <= N <= high and
with the specified mode between those bounds. The low and high bounds
default to zero and one. The mode argument defaults to the midpoint
between the bounds, giving a symmetric distribution.

New in version 2.6.

I fooled around with it a bit and wrote this rough demo:

The skewing and centering possible by varying the mode, are obvious,
but how is random.trangular() actually used?

Dick Moores

More information about the Tutor mailing list