Home > OS >  How to find the permutation distribution for a list of matrices for calculating Shanon entropy of an
How to find the permutation distribution for a list of matrices for calculating Shanon entropy of an

Time:02-25

Where H(X)=−∑xp(x)logp(x) is the Shanon entropy.In accordance to the paper "History of art paintings through the lens of entropy and complexity"

CodePudding user response:

I recently worked on Exploratory work with painting datasets, Hope this satisfies your problem. According to the reference paper length of distribution cannot exceed 24.

def permutataion_distribution(matrix_list):
'''
Returns the distribution of matrix permutaions.
Input: 
    matrix_list: the output of sliding_matrix.
output: 
    num_of_perm: list of number of each permutations in order recieved
    list_of_perm: list of permutations in order recieved
    distribution: distrubution
    
'''
list_of_perm = []
num_of_perm = []
distribution = np.zeros(24)
for i in matrix_list:
    mat_perm = np.argsort((np.array[i]).flatten())
    indicator = 0
    for j in range(0, len(list_of_perm)):
        if np.all(mat_perm == list_of_perm[j]):
            num_of_perm[j] = num_of_perm[j]   1
            indicator = 1
    if indicator == 0:
        list_of_perm.append(mat_perm)
        num_of_perm.append(1)
        
distribution = np.array(num_of_perm) / sum(num_of_perm)
return num_of_perm, list_of_perm, distribution
  • Related