triangular(self, left, mode, right, size=None, chunks='auto', **kwargs)
This docstring was copied from numpy.random.mtrand.RandomState.triangular.
Some inconsistencies with the Dask version may exist.
The triangular distribution is a continuous probability distribution with lower limit left, peak at mode, and upper limit right. Unlike the other distributions, these parameters directly define the shape of the pdf.
New code should use the triangular
method of a default_rng()
instance instead; please see the :None:ref:`random-quick-start`
.
The probability density function for the triangular distribution is
$$P(x;l, m, r) = \begin{cases}\frac{2(x-l)}{(r-l)(m-l)}& \text{for $l \leq x \leq m$},\\ \frac{2(r-x)}{(r-l)(r-m)}& \text{for $m \leq x \leq r$},\\ 0& \text{otherwise}. \end{cases}$$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.
Lower limit.
The value where the peak of the distribution occurs. The value must fulfill the condition left <= mode <= right
.
Upper limit, must be larger than :None:None:`left`
.
Output shape. If the given shape is, e.g., (m, n, k)
, then m * n * k
samples are drawn. If size is None
(default), a single value is returned if left
, mode
, and right
are all scalars. Otherwise, np.broadcast(left, mode, right).size
samples are drawn.
Drawn samples from the parameterized triangular distribution.
Draw samples from the triangular distribution over the interval [left, right]
.
Generator.triangular
which should be used for new code.
Draw values from the distribution and plot the histogram:
This example is valid syntax, but we were not able to check execution>>> import matplotlib.pyplot as plt # doctest: +SKIPSee :
... h = plt.hist(np.random.triangular(-3, 0, 8, 100000), bins=200, # doctest: +SKIP
... density=True)
... plt.show() # doctest: +SKIP
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them