Suppose I have the following representation of my data:
import numpy as np
import itertools
N = 100 # number of simulations
vars = 5 # number of variables to simulate
indices = list(range(vars))
sims = np.random.rand(vars,N) # simulation array of size (5,100)
combinations = list(itertools.combinations(indices,3)) # list of combinations of variables of length 3
# create a matrix which sums the variable simulations for each combination
combo_sims = np.empty((len(combinations),sims.shape[1]))
for i in range(len(combinations)):
combo_sims[i] = np.sum(sims[list(combinations[i])],axis=0)
- How can I get the ordered ranks for each row by column? The expected result would be a matrix of the same shape as combo_sims but with ranks instead of the sum of sims. For example,
[[1,0,2],[0,2,1],[2,1,0]]
should return:
[[2,1,3],[1,3,2],[3,2,1]]
- My actual data includes ~1,500,000 combinations and 10,000 simulations. What is the fastest way to get the results from question 1, keeping in mind memory utilization?
- Is there a more efficient way to set the combo_sims matrix?