[Tutor] What is random.triangular() used for
Emile van Sebille
emile at fenx.com
Sun Oct 24 22:29:44 CEST 2010
On 10/24/2010 1:17 PM Richard D. Moores said...
> In looking through the doc on the random module I came across
> random.triangular():
>
> ========================================
> 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:
> <http://tutoree7.pastebin.com/s4J0Ww12>
>
> The skewing and centering possible by varying the mode, are obvious,
> but how is random.trangular() actually used?
>
From people who would know found at
http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.triangular.html
"""The triangular distribution is often used in ill-defined problems
where the underlying distribution is not known, but some knowledge of
the limits and mode exists. Often it is used in simulations."""
HTH,
Emile
More information about the Tutor
mailing list