utils.stats.get_combinations
utils.stats.get_combinations(ind_list, type = 'indices' )
Generates all possible combinations of two values from a list of values. Order is not important.
Parameters
ind_list
list
A list of target indices.
required
type
str
The type of output, either ‘values’ or ‘indices’. Default is ‘indices’.
'indices'
Returns
list
list
A list of tuples, where each tuple contains a combination of two values. The order of the values within a tuple is not important, and each combination appears only once.
Examples
>>> from spotoptim.utils import get_combinations
>>> ind_list = [0 , 10 , 20 , 30 ]
>>> combinations = get_combinations(ind_list)
>>> combinations = get_combinations(ind_list, type = 'indices' )
[(0 , 1 ), (0 , 2 ), (0 , 3 ), (1 , 2 ), (1 , 3 ), (2 , 3 )]
>>> print (combinations, type = 'values' )
[(0 , 10 ), (0 , 20 ), (0 , 30 ), (1 , 20 ), (1 , 30 ), (2 , 30 )]