combinations

Numbers of combinations modulo m, efficiently

Numbers of combinations modulo m, efficiently Question: First of all I’m solving a programming problem rather than a math problem now. The question is Anish got an unbiased coin and he tossed it n times and he asked Gourabh to count all the number of possible outcomes with j heads, for all j from 0 …

Total answers: 3

Efficient sums of n-length combinations of array

Efficient sums of n-length combinations of array Question: Given the following input: An integer n, e.g., 36. An list/array mylist of length m, e.g., [0.0, 24.0, 48.0, 72.0, 96.0, 120.0]. Although the values in this example are evenly spaced and integer-valued floats, they are not necessarily evenly spaced and they are in general non-negative real …

Total answers: 2

Python separating the result of combinations

Python separating the result of combinations Question: I have the following code I took from Geeksforgeeks.org to obtain combinations of a list: from itertools import combinations def comb(lper,n): # A Python program to print all # combinations of given length # Get all combinations of list # and length n b = combinations(lper, n) return …

Total answers: 2

Pandas, combination of values and check if any of the combiantions is in a list

Pandas, combination of values and check if any of the combiantions is in a list Question: I have a df1 with some item_id‘s and some values for each item (called "nodes"): df1 = pd.DataFrame({‘item_id’:[‘1′,’1′,’1′,’2′,’2′,’2′,’3′,’3′],’nodes’:[‘a’,’b’,’c’,’d’,’a’,’e’,’f’,’g’]}) and a df2 that is a list of "vectors" where each row is a tuple of nodes (that can be in …

Total answers: 2

All combinations from multiple lists with different indices

All combinations from multiple lists with different indices Question: I have N lists of M elements (each list), N < M. I would like to have all the combinations from them with the conditions: each combination has N elements, all indices in combination (from the original list) are unique. Example for 3(N) lists of 4(M) …

Total answers: 4

Aggregate row pair combinations and calculate difference using pandas

Aggregate row pair combinations and calculate difference using pandas Question: I am using the context and code of this question here: Aggregate all dataframe row pair combinations using pandas import pandas import itertools mygenes=[‘ABC1’, ‘ABC2’, ‘ABC3’, ‘ABC4’] df = pandas.DataFrame({‘Gene’ : [‘ABC1’, ‘ABC2’, ‘ABC3’, ‘ABC4′,’ABC5’], ‘case1’ : [0,1,1,0,0], ‘case2’ : [1,1,1,0,1], ‘control1’:[0,0,1,1,1], ‘control2’:[1,0,0,1,0] }) >>> …

Total answers: 2