DistTriangular

class pydsol.core.distributions.DistTriangular(stream: StreamInterface, lo: float, mode: float, hi: float)[source]

Bases: DistContinuous

The Triangular distribution is a bounded distribution with a mode. Since ‘min’ and ‘max’ are functions in Python, the normally used terms (min, mode, max) to characterize a Triangular distribution have been replaced by (lo, mode, hi). For more information on this distribution see https://mathworld.wolfram.com/TriangularDistribution.html.

__init__(stream: StreamInterface, lo: float, mode: float, hi: float)[source]

Construct a new Triangular distribution. The Triangular distribution is a bounded distribution with a mode. Since ‘min’ and ‘max’ are functions in Python, the normally used terms (min, mode, max) to characterize a Triangular distribution have been replaced by (lo, mode, hi).

Parameters:
  • stream (StreamInterface) – the random stream to use for this distribution

  • lo (float) – the left bound of the distribution; lowest value that can be drawn

  • mode (float) – the mode of the distribution (peak with the highest probability of being drawn)

  • hi (float) – the right bound of the distribution; highest value that can be drawn

Raises:
  • TypeError – when stream is not implementing StreamInterface:

  • TypeError – when lo is not a float or int:

  • TypeError – when mode is not a float or int:

  • TypeError – when hi is not a float or int:

  • ValueError – when mode < lo or mode > hi or lo == hi:

draw() float[source]

Draw a value from the Triangular distribution.

probability_density(x: float) float[source]

Returns the probability density value for value x.

property lo: float

Return the parameter value lo

property mode: float

Return the parameter value mode

property hi: int

Return the parameter value hi

property stream: StreamInterface

Return the current random stream for this distribution.