Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes ! Thanks a lot You nbruin it is working like you said !!!

forget()
import numpy as np
DiceT=[[3,3,3,3,3,6],[1,4,4,4,4,4] ,[2,2,2,5,5,5]]
DiceColorT=['Red','Green','White']
DiceValueFrequencyT=[]
#Rf=[[3,5/6],[6,1/6]];Gf=[[1,1/6],[4,5/6]];Wf=[[2,1/2],[5,1/2]];
for die in range(0,len(DiceT)) :
    freqT = np.array(DiceT[die])
    #valueT = np.bincount(freqT)
    valueT = [Integer(a) for a in np.bincount(freqT)]
    #nonZeroValueT=np.nonzero(valueT)[0]
    nonZeroValueT=[Integer(a) for a in np.nonzero(valueT)[0]]

    show(valueT)
    show(nonZeroValueT)
    for value in range(0,len(nonZeroValueT)) :
        print int(len(DiceT[die]))
        # these Two lines are ok when uncommented
        #DiceValueFrequencyT.append([nonZeroValueT[value],(valueT[nonZeroValueT[value]]*(1/6))])
        #DiceValueFrequencyT.append([nonZeroValueT[value],(valueT[nonZeroValueT[value]]*(1/int(len(DiceT[die]))))])
        # but this one give false results when uncommented!
        #DiceValueFrequencyT.append([nonZeroValueT[value],(int(valueT[nonZeroValueT[value]])// int(len(DiceT[die])))])
        #DiceValueFrequencyT.append([nonZeroValueT[value],((valueT[nonZeroValueT[value]])// (len(DiceT[die])))])
        DiceValueFrequencyT.append([nonZeroValueT[value],((valueT[nonZeroValueT[value]])/ (len(DiceT[die])))])

show (DiceValueFrequencyT)