count - How to calculate total from Hashmap Java -


i have current output:

first clusters: [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]    0 : 4, probability: 0.8 , logval: -0.2575424759098898 1 : 1, probability: 0.2 , logval: -0.46438561897747244  0 : 3, probability: 0.6 , logval: -0.44217935649972373 1 : 2, probability: 0.4 , logval: -0.5287712379549449  0 : 5, probability: 1.0 , logval: 0.0  0 : 4, probability: 0.8 , logval: -0.2575424759098898 1 : 1, probability: 0.2 , logval: -0.46438561897747244  0 : 3, probability: 0.6 , logval: -0.44217935649972373 1 : 2, probability: 0.4 , logval: -0.5287712379549449 

then each logval total them example:
first data:

0 : 4, probability: 0.8 , logval: -0.2575424759098898   1 : 1, probability: 0.2 , logval: -0.46438561897747244    total[0] = (-0.2575424759098898) + (-0.46438561897747244) 

next, 2nd data:

0 : 3, probability: 0.6 , logval: -0.44217935649972373   1 : 2, probability: 0.4 , logval: -0.5287712379549449  total[1] = (-0.44217935649972373) + (-0.5287712379549449) 

and on until last data. i'm not sure how index of each data each data logval can total using hashmap.

this code far:

public static void printcount(hashmap<string, integer> countmap, int length) {     double logval = 0.0, entropy = 0.0, probability = 0.0;      set<string> keyset = countmap.keyset();      (string bit : keyset) {         //system.out.println(bit + " : " + countmap.get(bit));          probability = (double)countmap.get(bit)/length;          logval = (probability*(math.log(probability)/math.log(2)));          system.out.println(bit + " : " + countmap.get(bit) + ", probability: " + probability + " , logval: " + logval);          total = logval + logval;          system.out.println("total = " + total);      }      system.out.println();  } 

change:

total = logval + logval; system.out.println("total = " + total); 

by

string totalstring = "(" + logval + ") + (" + logval ")"; system.out.println("total = " + totalstring); 

if need store (you wrote total[0] = ... use string[] totals.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -