emat/util/distributions.py
def pert(
		lower_bound,
		upper_bound=None,
		*,
		rel_peak=None,
		peak=None,
		width=None,
		gamma=4.0,
):
	"""
	Generate a frozen scipy.stats.beta PERT distribution.

	For details on the PERT distribution see
	`wikipedia <https://en.wikipedia.org/wiki/PERT_distribution>`_.

	Args:
		lower_bound (numeric):
			The lower bound of the distribution.
		upper_bound (numeric, optional):
			The upper bound of the distribution.  Can be inferred
			from `width` if not given.
		rel_peak (numeric, optional):
			The relative position of the peak of the triangle.  Must
			be in the range (0,1).  If neither `peak` nor `rel_peak`
			is given, a default value of 0.5 is used.
		peak (numeric, optional):
			The location of the peak of the triangle, given as a particular
			value, which must be between the lower and upper bounds inclusive.
		width (numeric, optional):
			The distance between the lower and upper bounds.
			Can be inferred from those values if not given.

	Returns:
		scipy.stats.rv_frozen
	"""

	lower_bound, upper_bound, rel_peak, peak, width = _peaked_distribution_args(
		lower_bound, upper_bound, rel_peak, peak, width
	)

	a, b, c = [float(x) for x in [lower_bound, peak, upper_bound]]
	if gamma < 0:
		raise ValueError('gamma must be non-negative')
	mu = (a + gamma * b + c) / (gamma + 2)
	if mu == b:
		a1 = a2 = (1 + gamma/2)
	else:
		a1 = ((mu - a) * (2 * b - a - c)) / ((b - mu) * (c - a))
		a2 = a1 * (c - mu) / (mu - a)

	if not (a1 > 0 and a2 > 0):
		raise ValueError('Beta "alpha" and "beta" parameters must be greater than zero')

	return beta(a=a1, b=a2, loc=a, scale=c-a)

	Generate a frozen scipy.stats.beta PERT distribution.

	For details on the PERT distribution see
	`wikipedia <https://en.wikipedia.org/wiki/PERT_distribution>`_.

	Args:
		lower_bound (numeric):
			The lower bound of the distribution.
		upper_bound (numeric, optional):
			The upper bound of the distribution.  Can be inferred
			from `width` if not given.
		rel_peak (numeric, optional):
			The relative position of the peak of the triangle.  Must
			be in the range (0,1).  If neither `peak` nor `rel_peak`
			is given, a default value of 0.5 is used.
		peak (numeric, optional):
			The location of the peak of the triangle, given as a particular
			value, which must be between the lower and upper bounds inclusive.
		width (numeric, optional):
			The distance between the lower and upper bounds.
			Can be inferred from those values if not given.

	Returns:
		scipy.stats.rv_frozen
	
Generate a frozen scipy.stats.beta PERT distribution.
For details on the PERT distribution see
`wikipedia `_.
Generate a frozen scipy . stats . beta PERT distribution . For details on the PERT distribution see ` wikipedia ` _ .
def pert(
		lower_bound,
		upper_bound=None,
		*,
		rel_peak=None,
		peak=None,
		width=None,
		gamma=4.0,
):
	lower_bound, upper_bound, rel_peak, peak, width = _peaked_distribution_args(
		lower_bound, upper_bound, rel_peak, peak, width
	)
	a, b, c = [float(x) for x in [lower_bound, peak, upper_bound]]
	if gamma < 0:
		raise ValueError('gamma must be non-negative')
	mu = (a + gamma * b + c) / (gamma + 2)
	if mu == b:
		a1 = a2 = (1 + gamma/2)
	else:
		a1 = ((mu - a) * (2 * b - a - c)) / ((b - mu) * (c - a))
		a2 = a1 * (c - mu) / (mu - a)
	if not (a1 > 0 and a2 > 0):
		raise ValueError('Beta "alpha" and "beta" parameters must be greater than zero')
	return beta(a=a1, b=a2, loc=a, scale=c-a)
def pert ( lower_bound , upper_bound = None , * , rel_peak = None , peak = None , width = None , gamma = 4.0 , ) : lower_bound , upper_bound , rel_peak , peak , width = _peaked_distribution_args ( lower_bound , upper_bound , rel_peak , peak , width ) a , b , c = [ float ( x ) for x in [ lower_bound , peak , upper_bound ] ] if gamma < 0 : raise ValueError ( 'gamma must be non-negative' ) mu = ( a + gamma * b + c ) / ( gamma + 2 ) if mu == b : a1 = a2 = ( 1 + gamma / 2 ) else : a1 = ( ( mu - a ) * ( 2 * b - a - c ) ) / ( ( b - mu ) * ( c - a ) ) a2 = a1 * ( c - mu ) / ( mu - a ) if not ( a1 > 0 and a2 > 0 ) : raise ValueError ( 'Beta "alpha" and "beta" parameters must be greater than zero' ) return beta ( a = a1 , b = a2 , loc = a , scale = c - a )
Generate a frozen scipy.stats.beta PERT distribution.
Generate a frozen scipy . stats . beta PERT distribution .
"""
	Generate a frozen scipy.stats.beta PERT distribution.

	For details on the PERT distribution see
	`wikipedia <https://en.wikipedia.org/wiki/PERT_distribution>`_.

	Args:
		lower_bound (numeric):
			The lower bound of the distribution.
		upper_bound (numeric, optional):
			The upper bound of the distribution.  Can be inferred
			from `width` if not given.
		rel_peak (numeric, optional):
			The relative position of the peak of the triangle.  Must
			be in the range (0,1).  If neither `peak` nor `rel_peak`
			is given, a default value of 0.5 is used.
		peak (numeric, optional):
			The location of the peak of the triangle, given as a particular
			value, which must be between the lower and upper bounds inclusive.
		width (numeric, optional):
			The distance between the lower and upper bounds.
			Can be inferred from those values if not given.

	Returns:
		scipy.stats.rv_frozen
	"""
None
lower_bound
The lower bound of the distribution.
The lower bound of the distribution .
upper_bound
The upper bound of the distribution.  Can be inferred
from `width` if not given.
The upper bound of the distribution . Can be inferred from ` width ` if not given .
rel_peak
The relative position of the peak of the triangle.  Must
be in the range (0,1).  If neither `peak` nor `rel_peak`
is given, a default value of 0.5 is used.
The relative position of the peak of the triangle . Must be in the range ( 0 1 ) . If neither ` peak ` nor ` rel_peak ` is given a default value of 0 . 5 is used .
peak
The location of the peak of the triangle, given as a particular
value, which must be between the lower and upper bounds inclusive.
The location of the peak of the triangle given as a particular value which must be between the lower and upper bounds inclusive .
width
The distance between the lower and upper bounds.
Can be inferred from those values if not given.
The distance between the lower and upper bounds . Can be inferred from those values if not given .
gamma