python - entropy in txt file -
I have a text file that has the following numbers:
1231313123123123 1432423432535345 3532523452345345 1231423432453455 3434535345345345 3452353453253453 All lines are the same length, I want to calculate entropy on each line and get output like this: 2.64234234 2.65464564 2.35355435 etc.
/ code>
Now with this code of this code I have been given an entropy, what am I doing?
Thank you.
#! / Usr / bin / env python Import Mathematics DHH H (Data): If there is no data: Extra in Extra = 0 x (256): p_x = float (data.count (chr (x))) / Len (data) ) If p_x & gt; 0: entropy + = - p_x * math. Return Entry Failure = Open ('text.txt', 'r') for the line in the log (P_X, 2) failure: Print H ('Failure')
failed = open ('text.txt', 'r') for the row in failure: print h (line)
Comments
Post a Comment