Skip to main content

You need to flatten the list and convert elements to numeric values:

prob = Import["/home/Desktop/test1.txt", "Table"]// ToExpression// Flatten;

Then you can find Shanonthe Shannon Entropy (without a do loop and initialization):

alpha = 1.1;
t = Length[prob];
shanonshannon = Sum[-prob[[i]]*Log[prob[[i]]], {i, 1, t}];
Print[{alpha, shanonshannon}]

(* {1.1,0.0000793592} *)

You need to flatten the list and convert elements to numeric values:

prob = Import["/home/Desktop/test1.txt", "Table"]// ToExpression// Flatten;

Then you can find Shanon Entropy (without a do loop and initialization):

alpha = 1.1;
t = Length[prob];
shanon = Sum[-prob[[i]]*Log[prob[[i]]], {i, 1, t}];
Print[{alpha, shanon}]

(* {1.1,0.0000793592} *)

You need to flatten the list and convert elements to numeric values:

prob = Import["/home/Desktop/test1.txt", "Table"]// ToExpression// Flatten;

Then you can find the Shannon Entropy (without a do loop and initialization):

alpha = 1.1;
t = Length[prob];
shannon = Sum[-prob[[i]]*Log[prob[[i]]], {i, 1, t}];
Print[{alpha, shannon}]

(* {1.1,0.0000793592} *)

Source Link
Mahdi
  • 1.6k
  • 10
  • 23

You need to flatten the list and convert elements to numeric values:

prob = Import["/home/Desktop/test1.txt", "Table"]// ToExpression// Flatten;

Then you can find Shanon Entropy (without a do loop and initialization):

alpha = 1.1;
t = Length[prob];
shanon = Sum[-prob[[i]]*Log[prob[[i]]], {i, 1, t}];
Print[{alpha, shanon}]

(* {1.1,0.0000793592} *)