May-23-2020, 07:45 AM
(This post was last modified: May-23-2020, 07:45 AM by Shreya10o. Edited 2 times in total.)

I need all possible combinations of multiplications.

If I do this manually, it is giving a decimal number, but in this

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)