Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 All possible combinations of multiplications
#1
I need all possible combinations of multiplications.
If I do this manually, it is giving a decimal number, but in this loop all values are coming out to be 0. Please let me know where is it going wrong.

import numpy as np
import pandas as pd
q= {0: 0.52, 1: 0, 2: 0.46, 3: 0.02}
df6= {0: (pd.DataFrame(np.array([[ 0.77 , 0 , 0.04 , 0.12],
[0.00,  0,  0.00,  0.00],
[0.26,  0  ,0.35  ,0.30], 
[0.00 , 0,  0.00 , 1.00]]), index= [0,1,2,3],columns= [0,1,2,3])),
1: (pd.DataFrame(np.array([ [ 0.92,  0.08  ,0.0  ,0.00],
  [0.00 , 0.75 , 0.0 , 0.25],
  [0.67  ,0.33,  0.0  ,0.00],
  [0.18,  0.82  ,0.0 , 0.00]]),index= [0,1,2,3],columns= [0,1,2,3])),
2:  (pd.DataFrame(np.array([[  0.59 , 0.0  ,0 , 0.03],
  [0.00  ,0.0 , 0  ,0.76],
  [0.00,  0.0,  0 , 0.00],
  [0.00 , 1.0  ,0,  0.00]]),index= [0,1,2,3],columns= [0,1,2,3])), 
3:(pd.DataFrame(np.array([[ 0.32  ,0.68 , 0.0,  0.00],
  [0.00,  1.00,  0.0 , 0.00],
  [0.56 , 0.44  ,0.0  ,0.00],
  [0.07  ,0.79 , 0.0  ,0.14]]),index= [0,1,2,3],columns= [0,1,2,3])), 
4:(pd.DataFrame(np.array( [[0.12,  0.25,  0,  0.38],
  [0.09 , 0.28  ,0 , 0.44],
  [0.00  ,0.00 , 0  ,0.00],
  [0.00,  0.50,  0  ,0.50]]),index= [0,1,2,3],columns= [0,1,2,3]))}
from collections import Counter
t={}
high={}
for qq in range(4096):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        for n in range(4):
                            t[qq]=q[i]*df6[0].loc[i,j]*df6[1].loc[j,k]*df6[2].loc[k,l]*df6[3].loc[l,m]*df6[4].loc[m,n]
k = Counter(t) 
high = k.most_common(5) 
print(high)                   
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Do something with all possible combinations of a list 3Pinter 7 475 Sep-11-2019, 08:19 AM
Last Post: perfringo
  list of string combinations Skaperen 8 836 May-22-2019, 01:18 PM
Last Post: Skaperen
  Distances between all combinations in datatset amyd 6 940 Dec-13-2018, 01:23 PM
Last Post: amyd
  Combinations of list of lists dannyH 2 950 May-14-2018, 09:54 PM
Last Post: dannyH
  itertools: combinations Skaperen 2 1,141 Mar-19-2018, 01:37 AM
Last Post: Skaperen

Forum Jump:


Users browsing this thread: 1 Guest(s)