public double entropy(int c[]) {
        double entropy = 0;
        int i = 0;
        int sum = 0;
        double frac;
        while (c[i] != 0) {
            sum = sum + c[i];
            i++;
        }
        i = 0;
        while (c[i] != 0) {
            frac = (double) c[i] / sum;
            entropy = entropy - frac * (Math.log(frac) / Math.log(2));
            i++;
        }
        return entropy;
    }