median#

ParamDictND.median(*pattern)#

Calculate the median of all parameter values or a subset based on wildcard pattern.

Parameters:
*patternAny, optional

For subsets, the pattern requires one value for each dimension of the N-dim tuple key. The single-character string '*' (asterisk) can be used as a wildcard to represent all possible values for a dimension.

Returns:
int or float
Raises:
StatisticsError

If the ParamDict is empty.

TypeError

If the pattern includes non-scalar(s).

ValueError

If the pattern is not the same as the length of N-dim tuple keys.

ValueError

If the pattern has no wildcard or all wildcards.

Examples

>>> demand = ParamDictND({('A', 'B'): 10, ('B', 'C'): 20, ('A', 'C'): 15, ('C', 'A'): 16})

Sum over all parameter values:

>>> demand.median()
15.5

Sum over a subset based on wildcard pattern:

>>> demand.median('A', '*')
12.5
>>> demand.median('*', 'A')
16