Python Forum
All possible combinations of multiplications
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)                   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Finding combinations of list of items (30 or so) LynnS 1 838 Jan-25-2023, 02:57 PM
Last Post: deanhystad
  How can I find all combinations with a regular expression? AlekseyPython 0 1,637 Jun-23-2021, 04:48 PM
Last Post: AlekseyPython
  All possible combinations CODEP 2 1,826 Dec-01-2020, 06:10 PM
Last Post: deanhystad
  Triplet Combinations of All Values quest 2 1,939 Nov-05-2020, 09:22 AM
Last Post: quest
  Do something with all possible combinations of a list 3Pinter 7 4,018 Sep-11-2019, 08:19 AM
Last Post: perfringo
  list of string combinations Skaperen 8 3,249 May-22-2019, 01:18 PM
Last Post: Skaperen
  Python to iterate a number of possible combinations teflon 4 3,887 Apr-24-2019, 03:00 AM
Last Post: scidam
  Distances between all combinations in datatset amyd 6 3,802 Dec-13-2018, 01:23 PM
Last Post: amyd
  Combinations of list of lists dannyH 2 3,312 May-14-2018, 09:54 PM
Last Post: dannyH
  itertools: combinations Skaperen 2 2,984 Mar-19-2018, 01:37 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020